# Thresholding Images: How Do The Algorithms Work?

Home / Thresholding Images: How Do The Algorithms Work?

Image thresholding to show contrast

When you run an image through an optimization program, one of the portions of the algorithm will likely provide a service called “thresholding.” What is this service anyway, and why would you want a thresholding algorithm applied to your image?

## What is “Thresholding?”

The process of choosing a limit in the range of available colors, and assigning values above that limit to one color, and values below that limit to another color, is thresholding.

The left portion is the original image, the right portion has been subject to thresholding

An example of this is found in the optimization process. When an optimization program attempts to clarify a blurry area of high-contrast, it will simply separate the blurry shading into portions that are part of the dark area, and portions that are part of the lighter area. In order to do this, the algorithm compares the color value of each pixel to an established threshold. If the color value of the pixel is on the ‘dark’ side of the threshold, the pixel is converted to the full color value of the darkest color in the range. If the color value is on the ‘light’ side of the threshold, the pixel’s color value is changed to the lightest value in the range.

## How is Thresholding Useful?

Converting values to show contrast is extremely useful when optimizing text or other images that have clearly delineated edges. In order to apply the algorithm to a page with background color, or other images behind the text, it is necessary to pull the text layer off the page first.

Tell-tale signs of a document that has been selectively optimized in this fashion include:

• Extremely dark, monochromatic text: no shading or other coloration in the lines of the words denotes text that has gone through the thresholding process.
• A “halo” of light-colored pixels around the dark lines of text: this can indicate that the various shades, including noise, that naturally surrounds an image has been removed using a thresholding algorithm.
• A combination of the above two signs, with very dark text and very light surrounding pixels, is a good indication of the use of optimization techniques to brighten or clarify the lines or text in a document.

Before experimenting with this, or any other, optimization technique, it’s always a good idea to make an unedited copy of your original for safe-keeping.

Categories Uncategorized