Medical image segmentation is an important technical tool, OTSU algorithm is a common method in threshold segmentation, but with the increase of the number of threshold segmentation, the selection of its threshold is a big problem, and the segmentation effect is difficult to be guaranteed. In order to solve this problem, this paper proposes a random collision whale optimization algorithm to optimize OTSU for reliable image segmentation. The algorithm is called RCWOA for short. Firstly, the Halton sequence is used to uniformly initialize the population to make the population position distribution uniform, and then the dimensional Opposition-based learning of small-hole imaging is introduced to update the whale position and find out the missing feasible solution. Finally, the random collision theory is used to update the position of the optimal individual to improve the quality of the solution, At the same time, it also improves the search ability of the algorithm. In 12 test functions, RCWOA was compared with 6 other algorithms, demonstrating the feasibility and novelty of RCWOA. In 8 experiments of fundus image segmentation, RCWOA was compared with 9 other algorithms. The results showed that RCWOA had a Friedman test composite ranking of 1.3516, ranking at the forefront, and exhibited significantly improved segmentation quality.