Thresholding method is one of the most popular approaches for image segmentation where an objective function is defined in terms of threshold numbers and their locations in a histogram. If only a single threshold is considered, a segmented image with two classes is achieved. On the other hand, multiple classes in the output image are created with multilevel thresholding. Otsu and Kapur's procedures have been conventional steps for defining objective functions. Nevertheless, the fundamental problem with thresholding techniques is the determination of threshold numbers, which must be selected by the user. In that respect, thresholding methods with both techniques are user-dependent, and may not be practical for real-time image processing applications. In this study, a novel thresholding algorithm without any objective function has been proposed. Histogram curve was considered as an objective function. The peaks and valley in histogram have been detected by means of multimodal particle swarm optimization algorithms. Accordingly, valleys between two peaks have been assigned as thresholds. Consequently, the developed scheme does not need any user intervention and finds the number of thresholds automatically. Furthermore, computation time is independent of the number of thresholds, whereas computation time in Otsu and Kapur procedures depends on the number of thresholds.