Image - Threshold Color

For RGB or RGBa images, the Threshold Color command is similar to the Threshold command, but works on each individual RGB channel. Please see the Threshold command topic for details on the regular Threshold command.


Threshold Color is a very important command that is often used to prepare scanned images for vectorization or use as guide layers in the creation of drawings. It is also used to pick out colors and ranges of colors for graphics art editing and visual effects. It can be used with raster data images to pick out ranges of values to be used as selection masks.


Although it may be used in a simple interactive way to adjust images based on visual appearances using Preview, in sophisticated hands the Threshold Color dialog is a powerful instrument for choosing regions with specific color characteristics using Boolean combinations of RGB color values.



Shows distribution of intensity values. The taller the line, the more pixels have that intensity value.

[Upper edit box]

Beginning of threshold range.

[Lower edit box]

End of threshold range.

[Left Mouse Click]

Clicking the left mouse button in the histogram sets the left side of the threshold range.

[Right Mouse Click]

Clicking the right mouse button in the histogram sets the right side of the threshold range.


Choose standard, black or white threshold operation.


Both - All pixels within range are forced white. All others are forced black.


Black - All pixels within range are unchanged. All others are forced black.


White - All pixels within range are forced white. All others are left unchanged.


Choose use of channels in deciding whether to make a pixel black or white (or left unchanged).


All Channels - If pixel is in range in all channels, make it white, otherwise make it black.


Any Channels - If pixel is in range in any channel, make it white, otherwise make it black.


Each Channel - Apply the modify operation to each channel independently. For each pixel, the R, G, and B values will set to 255 if it is in range for that particular channel and to 0 otherwise.


Check to see effect in action.


Threshold Color provides three histogram threshold range panes, one each for the Red, Green and Blue channels. Each channel is considered independently, so the three histograms show the distribution of values for each channel independently of each other. The dialog opens with ranges set so that 50% of the pixels for each channel fall in range.






The histograms above show the RGB values for the sample bronze image. We apply various combinations of Modify and Match settings in the images below:




The default setting of Both forces all pixels within range to white and all pixels out of range to black. Using All channels means that a pixel's values must be in range in all three R, G and B channels. Note that the brightest regions are forced white and the darkest regions are forced black.




Changing the modify setting to White forces pixels in range to white and makes no change (leaves colors unmodified) for this pixels out of range. Note how those pixels forced black in the first image in this sequence retain their original colors.




Using Black for the modify setting forces pixels out of range to black and leaves unchanged those pixels in range. Note how the clouds and lighter part of the sky are left unchanged while all the darker pixels are forced black.




Referring once more to the RGB histograms, we can use Both for the modify setting so that all pixels will end up either black or white, and now we can change the match setting to Any Channel.




If any pixel falls in range within any of its RGB ranges, it will be forced white. Because many pixels in the image are in range in at least one of the three channels, this means that very many pixels will be forced white.




The final case requires the greatest thought to understand. Using Each Channel means that each color range is considered entirely on its own. For each pixel, if the Red value is within range it is set to 255 (that is "forced white"). If it is not in range it is set to 0 ("forced black"). This process is repeated for the Green and Blue values.


Using Each Channel with Both set means that every pixel in the image will be either black, white, red, blue, green, cyan, magenta or yellow because these are all the possible combinations of pixels having all or nothing values in the Red, Green and Blue channels. For information on why this is so see the Images and Channels topic.


The bronze monument ends up yellow because pixels there tend to have lots of red and green (so both the R and G channels are forced full ON), without as much blue. 50% of the high blue pixels are mostly in the sky and clouds, so the default settings for ranges tend to push the B values in the monument to zero. If R and G are 255 and B is zero the result is yellow.


A Cartographic Example


When vectorizing scanned map images into vector drawings, we can often improve the performance of our tools by carefully preparing the scanned image with Manifold image tools before beginning vectorization. Sophisticated use of the Threshold Color command will help us do this. This example shows how Threshold Color can be used to pick out regions of different colors.




For a sample image we will use a USGS DRG format scanned raster map downloaded from the USGS web site. Let's begin by getting rid of all of the black pixels.




To do this, we set up the channel controls with values from 0 to 10 for R, G and B with Modify set to White and a Match for Any Channel. We are telling Manifold to change to white all pixels within the range. The only pixels with such low values in RGB are black or near-black pixels, so this changes all of them to white. We apply this effect so there will be no more black pixels.




To make all pixels white except the bright red ones, we retain the White and Any Channel settings in the Modify and Match controls and choose a range of low values for red and high values for greens and blues. This turns everything white except those pixels with midrange or high values for Red that also have low values for Green and Blue. The result would be to make everything white except the bright red lines. Instead of applying this effect, let's see what we have to do to get the purple lines.




These are more difficult because they include Red color in their pixels as well as Blue and Green. We begin by setting all of the Red lines to white. Choosing any channel that has the above settings gets rid of bright red while retaining pink and purple. We apply this effect.




If we now choose high brightness value ranges for all three channels we get rid of the very lightest tones no matter what their color. The purple colors remain because they are not as bright as the light pink tones.




When looking at the three RGB histograms it is easy to make the mistake of thinking that a vertical line through the three histograms will show the R, G and B value for pixels on that line; however, this is a wrong understanding of the histograms. The histograms simply show the distribution of pixels by the total number of pixels at each R, G and B level. The histograms do not mean that these are the same pixels at each level even though that might often be the case. Certain color tones will often have similar values in R, G and B. For example, white clouds in a sky will show peaks in all three histograms because many pixels in those clouds will simultaneously have high values in all three channels.


To get the same pixel at each level, we need to average the R, G and B values into a combined intensity, which is how the regular Threshold command works. In many instances we can use the intensity as a proxy to pick out specific color shades. See the Threshold command topic for an example.