8.4.3 Threshold

The filter picks out objects from the surrounding background when brightnesses objects and background pixels are concentrated near two prevailing values. Usually the filter is used for receiving two-grade (binary, black and white) image of half-tone image or deleting the noise.
Marking of objects is done by means of defining the values of threshold dividing the areas of brightnesses distribution. If the brightness value of a defined pixel is more than the threshold pixel, than this point belongs to the object, if less — than to the background.
Filter parameters:

  • New value (newValue);
  • Block size (blockSize);
  • TreshValue (treshValue);
  • Operations (treshOperation).

The filter writes to the pixel New value (newValue) in the case if its brightness is higher than the average brightness in radius of the circle defined by the Block size (blockSize) parameter. New value should not equal zero.
Block size is a size of the analyzed area around the pixel. The more is this value, the less the sensitivity of the filter, the more noise is eliminated, yet, some details can be lost. The more is the TreshValue (treshValue) parameter, the brighter objects shall be defined at the image.
Selection of Block size and Threshold value values cannot be universal, it changes from task to task, and these tasks should be picked by hand for receiving the best result.
In threshold transformation you can select one of the Operations (treshOperation):
1) binary transformation (treshBinary). Pixel whose value is higher than that of a threshold becomes white, lower — black.
Threshold: binary transformation
2) inverse binary transformation (treshBinaryInv). Pixel whose value is higher than the threshold becomes black, lower — white.
Threshold: inverse binary transformation
3) reduced (treshTrunc).
Threshold: reduced
4) set to zero (treshToZero): Pixel value less than the threshold equals 0, higher than the threshold stays the same.
Threshold: set to zero
5) inverse, set to zero (treshToZeroInv). Pixel value higher than the threshold equals to 0, less than the threshold stays the same.
Threshold: inverse, set to zero
Please find more information on settings and the use of filter in the step by step instruction Tutorial on the use of Threshold filter.