Adaptive Thresholding of Images
An adaptive threshold binarizes a grayscale image based on the local character of the image (which you can select from any of the photos in the Wolfram image library).[more]
In this implementation, the adaptive method finds the mean value in each neighborhood. If the pixel value is greater than a threshold multiplied by this mean, the pixel is set to "1" (white), and otherwise is set to "0" (black). This changes a grayscale image to black and white. When applied to the three RGB channels of a color image, the result is a combination of an edge detection and a posterization; regions are outlined in bright colors.
With the infill option, the value of the central pixel is set to "0" (black), or it is left at the original value. This provides a dark halo around the edges of grayscale objects and sets a black outline around objects in a colored image.[less]
The filter has two controls: the size of the neighborhood and the threshold value. As the neighborhood is decreased, smaller features are revealed. As the threshold is increased, the image reliably darkens (it is lighter as the threshold is decreased). The checkbox lets you compare the original image, the outlined-thresholded image, and the infilled version. The "detail" slider lets you choose between a smaller image (faster) and better fidelity (slower to calculate).