SortBlobs
SortBlobs is used to sort the blobs referenced in a Blobls data structure in relation to a fixture.
By computing the position of the referenced blob's center of mass (centroid) relative to the specified image fixture coordinate system, SortBlobs sorts the referenced blobs based upon one of their measurement characteristics, such as the blob's distance along the x or y-axis, from a fixture origin or a grid, or the blob's angle or angular distance.
Each blob in the referenced Blobs data structure is examined, and depending upon the Sort By parameter setting, the blob is identified and its position is calculated by measuring either the blob's distance or angular relationship to a fixed location.
Once SortBlobs has sorted the referenced blobs, a new Blobs data structure and accompanying result table will be automatically inserted into the spreadsheet. The result table is sorted by how close the blob is to the chosen fixture, in descending order (the closest blob will be listed first, the next closest second, etc.).
SortBlobs is an extremely helpful function in instances where there are multiple blobs and the position of each blob in relation to the other blobs needs to be determined.
SortBlobs Inputs
Syntax: SortBlobs (Blobs,Number to Sort,Sort By,Fixture.Row,Fixture.Column,Fixture.Theta,Show)
Parameter | Description | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
This parameter references the spreadsheet cell that contains the Blobs data structure that is to be sorted. For more information, see Cell References - Relative/Absolute. |
|||||||||||||||||||
Specifies the maximum number of blobs (1 to 4096; default = 3) to return. Note: If the value
of this parameter
is greater than zero, SortBlobs will automatically insert a result table
containing a maximum of 10 entries
that correspond to the first 10 blobs in the Blobs data structure.
If you wish to display more entries, you can expand the table by copying
the last row and pasting additional rows at the end; make sure to increment
the index number of any newly-pasted row so that the proper blob is indexed.
|
|||||||||||||||||||
Specifies how the referenced blobs will be measured and sorted.
|
|||||||||||||||||||
Defines the referenced blob's center of mass (centroid) relative to a Fixture input or the output of a Vision Tool function's image coordinate system. Setting the referenced blob's center of mass relative to a Fixture ensures that if the Fixture is rotated or translated, the referenced blob will be rotated or translated in relation to the Fixture. For more information, see Fixture. The default setting is (0,0,0), the top leftmost corner of the image.
|
|||||||||||||||||||
Specifies the display mode for SortBlobs graphical overlays on top of the image.
|
SortBlobs Outputs
Returns |
A Blobs data structure containing the sorted blobs, or #ERR if any of the input parameters are invalid. |
When SortBlobs is initially inserted into a cell, a result table is created in the spreadsheet.
Note: If the value
of the Number
to Sort parameter
is greater than zero, SortBlobs will automatically insert a result table
containing a maximum of 10 entries
that correspond to the first 10 blobs in the Blobs data structure.
If you wish to display more entries, you can expand the table by copying
the last row and pasting additional rows at the end; make sure to increment
the index number of any newly-pasted row so that the proper blob is indexed.
|
SortBlobs Vision Data Access Functions
The following Vision Data Access functions are automatically inserted into the spreadsheet to create the SortBlobs Blobs data structure result table. For more information, see Blobs.
Spreadsheet Name | Function Name | Description |
---|---|---|
Row |
GetRow(Blobs, Blob Index) |
Returns the y-coordinate (Row) of the referenced blob's center of mass (centroid). |
Col |
GetCol(Blobs, Blob Index) |
Returns the x-coordinate (Column) of the referenced blob's center of mass (centroid). |
Angle |
GetAngle(Blobs, Blob Index) |
Returns the angle of the referenced blob's center of mass, relative to the center of the ROI. |
Color |
GetColor(Blobs, Blob Index) |
Returns the color value (0 = black, 1 = white) of the referenced blob. |
Score |
GetScore(Blobs, Blob Index) |
A measure of how closely the blob matches the criteria of a FindBlobs function. For more information, see FindBlobs. |
Area |
GetArea(Blobs, Blob Index) |
Returns the area of the referenced blob (measured in pixels). Note: If there are
holes in the blob, the Area value
will vary depending on whether or not the Fill Holes checkbox is enabled
or disabled. For more information, see Fill Holes.
|
Elongation |
GetElongation(Blobs, Blob Index) |
Returns a value that represents how the referenced blob's pixels are stretched out from the blob's center of mass (centroid). For instance, a circle would report 0 Elongation, while a nail would have a high Elongation value. |
Holes |
GetHoles(Blobs, Blob Index) |
Returns the number of holes contained within the referenced blob. |
Perimeter |
GetPerimeter(Blobs, Blob Index) |
Returns the length of the boundary around the referenced blob; the perimeter is calculated by counting the external edges of the pixels that form the boundary of the blob. |
Spread |
GetSpread(Blobs, Blob Index) |
Returns a value that represents how the referenced blob's pixels are distributed away from the blob's center of mass (centroid). For instance, a circular shaped object would have a lower Spread value than an oval shaped object. |
Additional data elements can be accessed using the following Vision Data Access functions:
Thresh |
GetThresh(Blobs) |
The Threshold value that was used to segment the image. |
NFound |
GetNFound(Blobs) |
The number of blobs found. |
MinRow |
GetMinRow(Blobs, Blob Index) |
Returns the topmost row coordinate for a square bounding box around the referenced blob, oriented to the image coordinate frame. Note: For an alternative
bounding box, with a varied orientation, see BoundingRectangle.
|
MinCol |
GetMinCol(Blobs, Blob Index) |
Returns the leftmost column coordinate for a square bounding box around the referenced blob, oriented to the image coordinate frame. Note: For an alternative
bounding box, with a varied orientation, see BoundingRectangle.
|
MaxRow |
GetMaxRow(Blobs, Blob Index) |
Returns the bottommost row coordinate for a square bounding box around the referenced blob, oriented to the image coordinate frame. Note: For an alternative
bounding box, with a varied orientation, see BoundingRectangle.
|
MaxCol |
GetMaxCol(Blobs, Blob Index) |
Returns the leftmost column coordinate for a square bounding box around the referenced blob, oriented to the image coordinate frame. Note: For an alternative
bounding box, with a varied orientation, see BoundingRectangle.
|
SortBlobs Example
The SortBlobs function is used to sort the blobs referenced in a Blobs data structure based on the referenced blobs' distance from a fixture. This example will help to illustrate how the SortBlobs parameter settings can be used to sort a set of blobs based upon their position relative to a fixture.
A SortBlobs function was inserted into an empty cell in the spreadsheet, automatically launching the SortBlobs property sheet.
In this example, the parameters are being set to sort the blobs identified in the earlier DetectBlobs example, using the blob returned by the FindBlobs example as a fixture. For more information, see FindBlobs.
Based upon these requirements, the SortBlobs parameters would be configured as follows:
- Blobs: This parameter was set as an absolute cell reference to the previously created DetectBlobs Blobs data structure.
- Number to Sort: This parameter was set to 6 because there are 6 known blobs that are being sorted.
- Sort By: This parameter was set to distance - From the Fixture origin. By choosing this parameter setting, the Fixture parameter will need to be set to determine the starting point for the measurements.
- Fixture: This parameter was set as cell references to the Row and Column coordinates returned in the FindBlobs example's Blobs data structure. By choosing this parameter setting, this ensures that the measurements and sorting will always originate from the specified feature in the image. It's possible to use another feature in the image, such as an edge, a point or another blob. For instance, in this example, the blob that was returned from the FindBlobs example will be used to set the Fixture coordinates.
- Show: The default setting was used, which only allows the result graphics to be displayed when the cell containing the Blobs data structure is selected, as in the example below.
After configuring the SortBlobs property sheet, a Blobs data structure and result data table are produced: