In the multilevel thresholding segmentation of the image, the classification number is always given by the supervisor. To solve this problem, a fast multilevel thresholding algorithm considering both the threshold value and the classification number is proposed based on the maximum entropy, and the self-adaptive criterion of the classification number is given. The algorithm can obtain thresholds and automatically decide the classification number. Experimental results show that the algorithm is effective.