Chapter 4
Blob Analysis
IMAQ Vision for LabWindows/CVI User Manual
4-2
ni.com
Correct Image Distortion
If you need to make accurate shape measurements based on the blobs in
an image containing perspective and nonlinear distortion errors, correct
the distortion using the calibration information you attached to your
image. Use
imaqCorrectCalibratedImage()
to correct distortion in
your grayscale image before thresholding it. See Chapter 6,
for more information about correcting an image using calibration
information.
Create a Binary Image
Threshold your grayscale or color image to create a binary image. Creating
a binary image separates the objects that you want to inspect from the
background. The threshold operation sets the background pixels to 0 in the
binary image, while setting the object pixels to a non-zero value. Object
pixels have a value of 1 by default, but you can set the object pixels to any
value or retain their original value.
You can use different techniques to threshold your image. If all the
objects of interest in your grayscale image fall within a continuous range
of intensities and you can specify this threshold range manually, use
imaqThreshold()
to threshold your image.
If all the objects in your grayscale image are either brighter or darker than
your background, you can use
imaqAutoThreshold()
to automatically
determine the optimal threshold range and threshold your image.
Automatic thresholding techniques offer more flexibility than simple
thresholds based on fixed ranges. Because automatic thresholding
techniques determine the threshold level according to the image histogram,
the operation is more independent of changes in the overall brightness and
contrast of the image than a fixed threshold. These techniques are more
resistant to changes in lighting, which makes them well suited for
automated inspection tasks.
If your grayscale image contains objects that have multiple discontinuous
grayscale values, use
imaqMultithreshold()
to specify multiple
threshold ranges.
If you need to threshold a color image, use
imaqColorThreshold()
.
You must specify threshold ranges for each of the color planes (either Red,
Green, and Blue or Hue, Saturation, and Luminance). The binary image
resulting from a color threshold is an 8-bit binary image.