Many previous methods for image thresholding focused on developing automatic algorithms to determine thresholds. However, most of the methods suffer from time-consuming computation for multilevel thresholding. Therefore, a fast and automatic thresholding method is desired for real-time applications. This paper proposes a new and faster method for bilevel as well as multilevel image thresholding. Taking (partial) derivatives of image between-class variance with respect to gray levels develops the proposed method. For bilevel thresholding, a nonlinear equation is derived to solve for an optimal threshold. For multilevel thresholding, a set of nonlinear equations is derived to solve for a set of optimal thresholds. A parameter is introduced to determine the class number for image classification by subjective determination of the ratio of image features to be kept after classification. Statistical performance analysis of the proposed method versus the Baysian classifier is included in this paper. Thresholding computation for the proposed method and Otsu's [N. Otsu, "A threshold selection method from gray-level histograms," IEEE Trans. Syst. Man, Cyber.