Threshold

NI Vision Assistant

Threshold

Segments pixels in grayscale images. The Manual Threshold operation enables you to select ranges of grayscale pixel values. Local threshold operations select pixels using a locally adaptive thresholding algorithm. Use local thresholds in applications whose images exhibit non-uniform lighting changes that may result from a strong illumination gradient or shadows. Automatic threshold operations select threshold ranges for you. Use automatic thresholds when you expect uniform lighting changes from image to image.

Main Tab

The following control is available on the Main tab.

  • Step Name—Name to give the step.

Threshold Tab

The following controls are available on the Threshold tab.

  • Look For
    Bright Objects Isolates pixels whose intensity values range from a user-specified value to 255.
    Dark Objects Isolates pixels whose intensity values range from 0 to a user-specified value.
    Gray Objects Isolates pixels whose intensity values lie within a user-specified range.
  • Threshold Type
    Image Source Opens the original input image.
    Manual Threshold Applies a threshold to the image based on the Minimum and Maximum threshold values that you enter. All pixels not contained between the Minimum and Maximum values are set to 0. All pixels that fall in the range are replaced by 1.
    Local Threshold: Niblack Calculates a threshold value for each pixel based on the statistics of surrounding pixels. This algorithm compensates for high lighting variations.
    Local Threshold: Background Correction Performs a background correction to eliminate non-uniform lighting effects and then performs thresholding using the interclass variance thresholding algorithm.
    Auto Threshold: Clustering Applies a threshold to an image based on a statistical technique called clustering.
    Auto Threshold: Entropy Applies a threshold to an image based on an image analysis technique called entropy.
    Auto Threshold: Metric Applies a threshold to an image by calculating the optimal threshold, which depends on the surfaces representing the initial grayscale, using the metric technique.
    Auto Threshold: Moments Applies a threshold to an image by using a statistical tool called moments, which recalculates a theoretical binary image.
    Auto Threshold: Inter Variance Applies a threshold to an image based on a classical statistical technique called interclass variance.
  • Threshold Range—Configurable only with a Manual Threshold.
    Minimum Lowest grayscale pixel value included in the manual threshold range. You can adjust the black cursor on the histogram to set the lower bound for this range when you are looking for bright or gray objects.
    Maximum Highest grayscale pixel value included in the manual threshold range. You can adjust the white cursor on the histogram to set the upper bound for this range when you are looking for dark or gray objects.
  • Histogram—Displays the total number of pixels in each grayscale value. From the histogram, you can discern if the image contains distinct regions of a certain grayscale value, and you can select grayscale pixel regions of the image by sliding the white and black cursors.
    Tips  
    • You can display the histogram of a portion of an image by drawing an ROI around the area of interest with one of the tools from the toolbar. The local histogram gives you valuable information about the threshold range you can select to keep or reject certain parts of the image.
    • Thresholding an image produces a binary images with pixel values of 0 and 1. You must use a binary color palette to display binary images.
  • Kernel Size—Size of the neighborhood around each pixel used to compute the mean value. The Kernel Size is typically the size of the object you want to isolate with the threshold. This control is configurable only with a local threshold.
    Tip  You can get the approximate size of an object in your image by drawing an ROI around the object. ROI Size displays the size of the last ROI drawn. Click Push Results to apply the ROI Size to the Kernel Size.
  • Deviation Factor—Determines the sensitivity of the algorithm. Values range from 0 to 1, with 0 being the most sensitive to noise. The lower the Deviation Factor, the closer the pixel value must be to the mean value to be selected as part of a particle. This control is configurable only with the Local Threshold: Niblack Threshold Type.