Auto Threshold

The Auto Threshold module will automatically threshold the current image into a binary black and white image. The threshold level is automatically determined based on the method selected. The appropriate method to use will depend on your application. Select Cluster (Otsu) if you are looking for a standard technique that is most often referenced by the current machine vision literature.

This module is useful when working with blob analysis or shape recognition whose background image can change and a manual threshold is not reliable enough.



1. Threshold Method - The following briefly outlines the algorithms used by the thresholding methods to allow you to chose the most appropriate for your application. Note that they all operate on the image's histogram.

  • Single Peak - Detects the highest peak in the histogram and preserves pixels around that peak as defined by the Single Peak Range.
  • Two Peaks - Detects the two highest peaks in the histogram separated by the distance specified. The distance will ensure that peaks close to each other are not selected. The threshold is then found by finding the deepest valley between these two peaks.
  • Mean Level - the average pixel value is determined using the image histogram. All pixel intensities below that value are set to black with all pixel intensities above the mean set to white.
  • Black Percent - Also known as P-Tile. The threshold level is set based on the specified percent of suggested dark pixels (or background) there are in the image. The histogram is used to indicate how much of the image at a certain threshold would be set to black. Once this amount exceeds the specified percent the current histogram index (0-255) is used as the threshold.
  • Edge Percent - Similar to the black percent the edge percent threshold is determined by the specified percent of edge pixels that exist below the threshold. Instead of just counting every pixel the edge percent bases its measurement on how much a pixel is part of an edge by performing a laplacian filter prior to threshold determination.
  • Entropy (Kapur) - Utilizes Kapur's entropy formula to find the threshold that minimizes the entropy between the two halves of the histogram created by a threshold.
  • Cluster (Otsu) - One of the most popular threshold techniques that creates two clusters (white and black) around a threshold T and successively tests the within-class variance of the clusters for a minimum. This algorithm can also be thought of as maximizing the between-class variance.
  • Symmetry - Assumes that the largest peak in the histogram is somewhat symmetrical and uses that symmetry to create a threshold just before the beginning of the largest peak. This technique is particularly useful to segment objects from large background planes.
  • Triangle - Works well with histograms that don't have well defined peaks. This technique finds the maximum distance between a suggested threshold value and a line that connects the first non-zero pixel intensity with the highest peak. Inherent in this technique is the distance of a point to a line equation.
  • Clip - Removes pixels in the upper and lower X percent of intensity range. This is useful if you have noise in the higher and lower intensity ranges.

2. Single Peak Range - Defines how wide the range is for the single peak. For example, if the current image has the most pixels at 160 then a value of 10 would preserve those pixels whose values are from 150 to 170.

3. Two Peak Separation - Defines the required distance between the two selected highest peaks. The larger the value the more separated the peaks need to be.

4. Black & Edge Percent - Defines the percentage amount as needed by the Black Percent and Edge Percent methods.

5. Symmetry Percent - Specifies the percent amount when calculating the start and end of the highest peak.

6. Adjustment Range - Limits the area of the histogram being considered by the Auto Threshold module. For example, if the image is very bright the chosen threshold might be set to 240 in order to create a black and white image. Setting the Maximum range to 170 would force that setting back down to 170 instead of 240 which would then prevent really white images from being incorrectly thresholded. This global restriction can be used to prevent the auto-threshold from using too aggressive a value when working with darker or lighter images.


Source ImageThresholded


AUTO_THRESHOLD - the threshold level chosen based on the selected thresholding technique.

See Also

Manual Thresholding
Adaptive Thresholding
Population Thresholding

 New Post 

Auto_Threshold Related Forum PostsLast postPostsViews
source code??
Hi, i am using roborealm for my final year project and i am expected to explain the process of my image analysis...
7 years 4 2274