In this paper we propose a) a fast and robustglobal gray-level thresholding method based on object size,where the selection of threshold level is based on recall andmaximum precision with regard to objects within a givensize interval, and b) an adaptive thresholding method whereeach object is thresholded optimizing its shape. The methodsare based on on the component tree representation, whichcan be computed in quasi-linear time. We show that forreal images of cell nuclei and synthetic data sets mimickingfluorescent spots the proposed methods are more robust thanall standard global thresholding methods in ImageJ andCellProfiler. The methods can be extended to compute anyfeature measurements that can be calculated in a cumulativeway, and hold great potential for applications where a prioriinformation on expected object size and shape is available.