Blob tool. UniVision ProInspect
Mainos
Mainos
PRO Inspect
45
6.6 Blob tool
This chapter describes Blob, a vision tool that provides advanced blob analysis of images. This chapter contains the following sections.
The blob tool is used to detect and measure two-dimensional shapes (blobs) within images.
Blob analysis can provide your application with information about the number, location, shape, and orientation of blobs within an image.
Image Segmentation
Since blob analysis is fundamentally a process of analyzing the shape of a closed object, before blob analysis can be performed on an image, the image must be segmented into those pixels that make up the blob being analyzed, and those pixels that are part of the background.
In general, all images that are used for blob analysis start out as grey-scale images of scenes. While it might be easy for a human observer to identify blobs or objects within the scene, before blob analysis can analyze the image, each pixel in the image must be assigned as an object pixel or a background pixel.
Typically object pixels are assigned a value of 1 while background pixels are assigned a value of 0.
Several techniques can be used to segment images into object pixels and background pixels. The following sections describe these techniques.
Binary Thresholding
The simplest technique for segmenting an image is to pick a threshold pixel value. All pixels with grey-scale values below the threshold are assigned as object pixels, while all pixels with values above the threshold are assigned as background pixels. This technique is called binary thresholding or hard thresholding.
Figure 6-19 shows an idealized scene, the application of a hard threshold, and the resulting segmentation of the image into object and background pixels. In the example below, a threshold value of 150 was used. All pixels with values greater than or equal to 150 are treated as background; all pixels with values less than 150 are treated as object.
Fig. 6-18 Segmenting an image with a binary threshold
PRO Inspect
46
Regional thresholding
Binary thresholding, although a simple and fast method has several drawbacks.
Binary threshold works well with high contrast blobs and images with a homogeneous background level.
In addition it cannot cope with variations of light or reflectivity of the parts.
An alternative method of thresholding with better performances in case of non homogeneous background and light variations is called regional thresholding.
With the regional thresholding the level of a pixel is checked against a neighborhood of pixels instead of a fixed threshold.
There are two variants of regional thresholding.
Unsigned difference
With unsigned difference the absolute value of the difference between the pixel level and a weighted average of its neighbors is taken into account. This method provides slightly higher speed but cannot distinguish the color of the blobs. The threshold value has the dimension of a grey level (from 0 to 255).
Signed difference
Signed difference take into account the sign of the difference. Thus it can distinguish blobs having levels above or below the background. The thresholds in this case are two signed values (up to +127 for white blobs, down to –127 for black blobs).
Model difference
Model difference is different from other segmentation techniques in that it uses a model image of the region of interest stored at train time. The difference between the model and the run time image is compared to a fixed threshold.
Model difference is the segmentation method more suited to images having a background pattern. However a fine alignment is required to inspect scenes with strong patterns. Consider also the PatInspect tool for this purpose.
Connectivity Analysis
Once an image has been segmented into object pixels and background pixels, connectivity analysis must be performed to assemble object pixels into connected groups of object pixels or blobs.
Connectivity analysis uses connectivity criteria to assemble the object pixels within the image into discrete, connected blobs. In general, connectivity analysis is performed by joining all contiguous object pixels together to form blobs.
Object pixels that are not contiguous are not considered to be part of the same blob.
Properties of Blobs
Once an image has been segmented, and the blob or blobs have been located and identified, an application can begin to consider information about the blob or blobs.
A blob is an arbitrary two-dimensional shape. The shape of a blob can be described using a number of different measures. The measures that the Blob tool returns are depicted in the following sections.
PRO Inspect
47
Figure 6.20 illustrates the geometric properties of a blob.
Fig. 6-19 Blob geometric properties
Area
The area of a blob is defined as the sum of the weighted pixel values for every nonzero pixel in the blob. If a hard binary threshold was applied to the image to segment it, then the area is simply the number of nonzero pixels in the blob. If grey-scale analysis is being performed, then the area is the sum of the pixel weights.
Perimeter
Center of Mass
The perimeter of a blob is the length of the outside edge of the blob. A blob’s perimeter is computed by counting the number of pixel edges between pixels with nonzero values and pixels with values of 0.
Because computing the perimeter in this way tends to produce a perimeter that is lager than the actual blob perimeter, a correction factor is applied to the perimeter.
The center of mass of a blob represents the blob’s balance point. If a sheet of a uniform material were cut out in the shape of the blob, the point upon which the blob would balance is the center of mass.
The center of mass is computed by determining the average weighted pixel location for each pixel in the blob in the x-axis and y-axis.
Principal Axes
The major axis of a blob is the axis about which it would be the easiest to spin the blob. The major axis of a blob always passes through the blob’s center of mass. The minor axis of a blob is defined as the axis through the center of mass about which the second moment of inertia is the largest. The minor axis of a blob is the axis about which it would be the hardest to spin the blob. The minor axis of a blob is always a line that is at 90
? ?
to the major axis passing through the center of mass. Together, the major and minor axes are referred to as the principal axes.
PRO Inspect
48
Geometric Extents
The geometric extents of a blob are the distances between the blob’s center of mass and the four sides of a rectangle that is oriented to the blob’s principal axes and that completely encloses all the blob’s pixels.
Inspect or measure mode
The blob tool can be used for two separate purposes.
Inspect mode
Inspect mode verifies the absence of defects. Any segmented pixel is considered a defect. The blob tool allows to specify certain tolerance on the size and number of defects.
Defects are distinguished in “major” and “minor” defects based on their size.
Major defects have a size above a major limit. Minor defects have a size below the major limit and above a minor limit. Defects below the minor limit are neglected.
The pass/fail decision is than taken as described by the following table:
Major defect count > 0
No major defect,
Minor defect count > limit
No major defect, minor defect count < limit
Fail
Fail
Pass
Measure mode
Measure mode verifies the properties of the blob against a set of tolerances.
Note that the properties of a single blob are taken into account. In case of multiple blobs found in the region of interest the larger blob is selected.
Blob settings
Blobs property page
The Blob page contains the parameters and specification relevant for the reject decision.
Inspect mode
Defect area limit – Tolerable area of all defects
Tolerable number of minor defects
Minor defect area limit
A limit for the total defect area.
Limit for the count of minor defects.
Limit for the size of defect. Defect larger than this limit are deemed as “ major defect”
PRO Inspect
49
Measure mode
Position offset
Rotation
Perimeter
Area
Area/Perimeter ratio
Axis calculation mode
Limit for the position offset of the blob fount relative to the train time situation.
Limit for the rotation of the blob relative to the train time situation.
Limit for the perimeter size relative to a specified nominal value.
Limit for the blob area relative to a specified nominal value.
Limit for the area/perimeter ratio relative to a specified nominal value. The ratio provides a basic indication of the blob shape.
?
Inertia axis
?
Bounding box
(un-rotated)
Principal axes of inertia
The axes of the bounding rectangle parallel to the x-y axis
?
Bounding box
(rotated)
The axes of the bounding rectangle parallel to the principal inertia axes.
Axis tolerances
(H, V)
Tolerances for horizontal (H) and vertical (V) axis.
Threshold page
The threshold page contains settings that influence the segmentation process.
The threshold page includes an image panel showing the result of the segmentation. The graphics is updated interactively at any parameter change.
The image panel shows a graphics that change with the setting of an option mode with the following possible choices:
?
Defects – bounding boxes
?
Blobs – segmented pixels in red
?
Threshold – mapped image – red for lighter pixels – blue for darker pixels
PRO Inspect
50
Mode (of segmentation)
Mode
Regional thresholding with Regional thresholding with unsigned unsigned difference
?
Unsigned difference difference
Regional thresholding with unsigned difference
?
Signed difference Regional thresholding with unsigned difference
Filter size
For regional thresholding mode specifies the size of the neighborhood of pixels taken into account to compute the difference
Sensitivity
Sensitivity mode
Black
White
Min area
Black
White
Black and white
Only “black” pixels, darker than the background are segmented
Only “white” pixels, lighter than the background are segmented
Black and white pixels are segmented with separate thresholds
Threshold for black pixels
Threshold for white pixels
Blob size limit. Blobs smaller than this limit are neglected
Blob results
Inspect mode
?
Number of blobs
?
Max blob size
Measure mode
The following measurement are reported for the largest blob
?
Perimeter
?
Area
?
Shape factor (Area/perimeter ratio)
?
H and V axis size
?
Position (x, y of the center of mass)
?
Offset (x, y relative to the model position)
?
Angle (of major inertia axes)
Lataa
Mainos