Справочник Пользователя для National Instruments IMAQ Vision for LabWindows TM /CVI

Скачать
Страница из 119
Chapter 4
Performing Particle Analysis
4-2
ni.com
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 using either 
the RGB or HSL color model. The binary image resulting from a color 
threshold is an 8-bit binary image.
Improve the Binary Image
After you threshold your image, you may want to improve the resulting 
binary image with binary morphology. You can use primary binary 
morphology or advanced binary morphology to remove unwanted 
particles, separate connected particles, or improve the shape of particles. 
Primary morphology functions work on the image as a whole by processing 
pixels individually. Advanced morphology operations are built upon the 
primary morphological operators and work on particles as opposed to 
pixels. Refer to Chapter 9, Binary Morphology, of the IMAQ Vision 
Concepts Manual
 for lists of which morphology functions are primary 
and which are advanced.
The advanced morphology functions require that you specify the type of 
connectivity
 to use. Use 
connectivity-4
 when you want IMAQ Vision to 
consider pixels to be part of the same particle only when the pixels touch 
along an adjacent edge. Use 
connectivity-8
 when you want IMAQ Vision 
to consider pixels to be part of the same particle even if the pixels touch 
only at a corner. Refer to Chapter 9, Binary Morphology, of the 
IMAQ Vision Concepts Manual for more information about connectivity.
Note
Use the same type of connectivity throughout your application.