Dynamic Thresholding

greyscale image
It is often useful to simplify images by reducing the number of colors or grey values. Images with fewer colors can be compressed to take up less space on disk and download faster over a network. Images with fewer colors are also less expensive to print. One problem with reducing an image's colors is that it's easy to lose too much of the high-frequency edge information. Edges communicate shape and texture, which people use to identify the subject of the image as well as the expression or gesture.

thresholded at 83
“Thresholding” is one of the simplest methods for reducing an image's colors. Consider a greyscale image, like the one above, which has 256 “colors” — pixel values that range from 0 (black) to 255 (white). To convert the greyscale image to a two-color image by thresholding, each pixel is examined. If the pixel has a value below the threshold it is replaced with 0, otherwise it is replaced with 255. Any value may be chosen as a threshold. Here is the greyscale image with the threshold set to 83.

thresholded at 128
Here is the same image with the threshold set to 128. One problem with thresholding is that it only preserves image details in a narrow range of values around the threshold. In this example a threshold of 83 preserves the edges of the glasses and lips, but not the forehead wrinkles. A threshold of 128 preserves the forehead wrinkles, but loses detail in the eyes.

blurred copy

Dynamic thresholding is an alternative to regular thresholding.

Instead of using a single threshold value, the dynamic thresholding algorithm uses a different threshold for each pixel. The threshold is chosen by starting with a base threshold and adding the greyscale value of the corresponding pixel in a blurred copy of the original image.


dynamic threshold

Dynamic thresholding uses a lower threshold in dark areas of the image and a higher threshold in light areas of the image. In most cases, dynamic thresholding does a good job of preserving high-frequency details such as edges, even in images of subjects with uneven illumination where edges may move through both light and dark areas of the image.

I have used variations of dynamic thresholding for creating very small icons of faces and for simplifying images to make them look more like comics.

return to ImageBeat home web mediasoftware

Copyright © 2000-2004 Jonathan Helfman