Example of Histograms

The figure below shows 10 dark rings on a light gray background. The following describes histogram using an example that the parts are detected by Correlation object and Blob object.

Example Image with 10 Rings using Corr01 object

Histograms with Correlation Objects

Figure below shows the [Histogram] dialog box that was generated for the Corr01 object. Notice that it shows the spread of pixels over the various gray levels very nicely so that we can see how the image is dispersed. You can easily see that there are a lot more light pixels than dark pixels which is true since most of the image in Example of Histograms is the gray background and not the dark rings.

Example Histogram for Correlation object “Corr01”

Histograms with Blob Objects

When using the [Histogram] dialog box with Blob object, some points differ from that of Correlation object. Notice that there are 2 vertical bars with values attached at the base called ThresholdLow and ThresholdHigh. These are Blob object properties that are used to specify which gray levels to include as part of the found blob and which to include as part of the background.

Example Histogram for Blob object “Blob01” (Dark on Light)

The area between the ThresholdLow and ThresholdHigh slider bars is the grouping of pixels that represent the levels of gray we want to define as dark or white pixels, which is set with the ThresholdColor property. The Polarity property defines whether we are looking for dark objects or light objects.
Adjusting the ThresholdLow and ThresholdHigh Properties
Look at the above figure again. Notice that the ThresholdLow property is set to 0 and the ThresholdHigh property is set to 128. These are the default values for these Blob object properties. When we first run the Blob object on the Rings image (with NumberToFind set to 10) we get a result as shown in the figure below. Notice that the Extrema for many of the blobs found does not go around the outer parts of the rings and in some cases only a portion of the part is detected as a blob or 1 part is found as 2 blobs (see the arrows in the figure below that indicate the problem areas). This is because the ThresholdLow and ThresholdHigh properties have not adjusted based on the Histogram results.


Image of 10 Rings with poor threshold settings

If we use the [Histogram] dialog box to examine the histogram for the rings image we see a large distribution of gray starting at a level around 32. Then another large peak starts at around 170. Since the largest distribution of gray in the rings image is the light background it is easy to see that the distribution of pixels above 170 is or the background. Also, since the other peak in the histogram runs from about 32 till up to 170 this shows the distribution of the darker parts of our image which are the rings (the part we are interested in). The ThresholdLow and ThresholdHigh values can be adjusted so that our found boxes for each blob fall right around the outer bounds of the rings. This is done by clicking on the ThresholdHigh and ThresholdLow bars in the [Histogram] dialog box and dragging them to the positions as shown in the figure below.


Histogram of Rings Image with better Threshold Settings

If we look at the rings image after running the Blob object with our new ThresholdLow and ThresholdHigh settings, we can see that the returned results are much more in keeping with what we wanted. Each ring is now found with the correct extrema for each blob.


Image of 10 Rings with Improved Threshold Settings

Also, the ThresholdAuto checkbox is located at the lower right corner of the dialog box. By checking the checkbox, appropriate ThresholdLow and ThresholdHigh values considering from the search window can be set. In the case of the above figure, the ThresholdLow property value is set to 0, and the ThresholdHigh property value is set to 164. The status of the ThresholdAuto checkbox is linked to the ThresholdAuto property value. If the ThresholdAuto property value is “True”, the threshold values are calculated each time the vision sequence is executed. This enables the blob detection to function properly even when the lightening system is changed.

KEY POINTS


If ThresholdAuto is set to “True”, the setting value declines to the threshold value which is capable to detect blobs (at least one blob can be detected) even when the image is homogeneous (all black or white), such as when the target work piece is unable to be captured.