Morphological filtering is known for its flexibility in locally modifying geometrical features of three dimensional data, or image functions. The topic in this paper is on adaptive thresholding of multilevel image functions to extract application-specific features from grayscale images. By adaptive thresholding, we mean that the process of binarizing grayscale images is locally adjusted. The geometric features to be extracted are furnished by specifics from the application requirements, e.g., a binary version is needed from a photo to extract letters from a car license plate such that the binarized image is specifically representing the information about letters around the license plate while ignoring other background information. A contour function is used as the adaptive thresholding layer for the grayscale image. After the first thresholding, a binarized version is obtained and then local geometric parameters about the binary image are measured through a skeletonization process. The parameters from skeletonization are compared with the feature descriptions and a contour function is redefined and used for adaptively thresholding the grayscale image. A skeletonization process is then applied to the binarized image to extract local geometric parameters to meet the application- specific requirement. Application of the developed adaptive thresholding algorithm includes examples in text image binarization, object feature binarization against surrounding background, and glass flaw detection.