FindBlobs

FindBlobs is used to filter and sort the blobs returned in a Blobs data structure.

Using the FindBlobs parameter settings, a formula is created that calculates a score to measure how closely the blobs referenced in the Blobs data structure match an “ideal” blob. Based upon the parameter settings, FindBlobs will in turn return only those blobs that match the specified requirements.

Each blob in the referenced Blobs data structure undergoes a two-step process of analysis: First, each of the individual FindBlobs parameter settings creates a formula that evaluates that particular parameter value. For instance, the Angle score would be computed by dividing the differences of the Range and the Angle parameter's Angle value and the Range and referenced blob's Angle value, multiplied by the Weight value. After the individual scores have been computed, each of the individual parameter scores are added together and divided by the sum of the individual Weight parameter values. This score is then compared against the Accept Thresh value to determine whether or not the blob meets the specified requirements.

Once FindBlobs has filtered and sorted the extracted blobs, a new Blobs data structure and accompanying result table will be automatically inserted into the spreadsheet. The result table is sorted by how closely the found blobs match the configured requirements, in descending order.

FindBlobs can be extremely useful in classifying features for defect detection. For example, if the job were to detect scratches on a surface, FindBlobs could be configured to return only those blobs with higher Elongation values. Or, if the goal was to detect jagged edge defects, FindBlobs could be configured to return only those blobs with higher Perimeter or Spread values.

FindBlobs Inputs

Syntax: FindBlobs(Blobs,NumbertoFind,AcceptThresh,Angle.Angle,Angle.Range,Angle.Weight,Area.Area,Area.Range,Area.Weight,Elongation.Elongation,Elongation.Range,Elongation.Weight,Holes.Number,Holes.Range,Holes.Weight,Perimeter.Perimeter,Perimeter.Range,Perimeter.Weight,Spread.Spread,Spread.Range,Spread.Weight,Show)

Parameter Description

Blobs

This parameter references the spreadsheet cell that contains the Blobs data structure that is to be filtered and sorted. For more information, see Cell References - Relative/Absolute.

Number to Find

This parameter specifies the maximum number (1 to 4096; default = 3) of blobs to return. If there are more blobs in the image whose scores exceed the Accept Thresh setting, the blobs with the highest scores will be selected.

Note: If the value of the Number to Find parameter is greater than zero, FindBlobs 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.

Accept Thresh

Specifies the minimum acceptable match score (0 to 100; default = 10). FindBlobs will return only those blobs with match scores exceeding the Accept Thresh. The match score is computed with the following formula:

(Angle score + Area score + Elongation score + Holes score + Perimeter score + Spread score) * (100/Sum of the parameters' Weight values)

Angle

This parameter is used to configure the scoring formula that identifies the ideal Angle score of found blobs.

ClosedAngle Scoring Formula

The FindBlobs Angle score is computed by using the following formula:

Angle Score = [(Range + Angle) - BlobAngleVal]/Range * WeightVal

BlobAngleVal = the referenced blob's output Angle value

WeightVal = Weight/(sum of all weight values) * 100

Angle

The ideal blob angle (-360 to 360; default = 0).

Range

The blob angle tolerance, in similarity scoring (0 to 360; default = 0).

Weight

The relative importance of blob angle, in similarity scoring (0 to 100; default = 0).

Area

This parameter is used to configure the scoring formula that identifies the ideal Area score of found blobs.

ClosedArea Scoring Formula

The FindBlobs Area score is computed by using the following formulas, depending on the BlobAreaVal and the Area value:

  • If the BlobAreaVal is greater than the Area value, this formula is used:

    Area Score = [(Range + Area) - BlobAreaVal]/Range * WeightVal

  • If the BlobAreaVal is less than the Area value, this formula is used:

    Area Score = [BlobAreaVal - (Area - Range)]/Range * WeightVal

    • BlobAreaVal = the referenced blob's output Area value
    • WeightVal = Weight/(sum of all weight values) * 100

Area

The ideal blob area size, in pixels (0 to 900000; default = 1000).

Range

The blob area tolerance, in similarity scoring (0 to 900000; default = 20000).

Weight

The relative importance of blob area, in similarity scoring (0 to 100; default = 50).

Elongation

This parameter is used to configure the scoring formula that identifies the ideal Elongation score of found blobs.

ClosedElongation Scoring Formula

  • The FindBlobs Elongation score is computed by using the following formula:

    Elongation Score = [(Range + Elongation) - BlobElongationVal]/Range * WeightVal

    • BlobElongationVal = the referenced blob's output Elongation value
    • WeightVal = Weight/(sum of all weight values) * 100

Elongation

The ideal blob elongation (0 to 900000; default = 1).

Range

The blob elongation tolerance, in similarity scoring (0 to 900000; default = 2).

Weight

The relative importance of blob elongation, in similarity scoring (0 to 100; default = 50).

Holes

This parameter is used to configure the scoring formula that identifies the ideal Holes score of found blobs.

ClosedHoles Scoring Formula

  • The FindBlobs Holes score is computed by using the following formula:

    Holes Score = [(Range + Number) - BlobHolesVal]/Range * WeightVal

    • BlobHolesVal = the referenced blob's output Holes value
    • WeightVal = Weight/(sum of all weight values) * 100

Number

The ideal blob hole count  (0 to 10000; default = 0).

Range

The blob hole count tolerance, in similarity scoring (0 to 10000; default = 2).

Weight

The relative importance of blob hole count, in similarity scoring (0 to 100; default = 0).

Perimeter

This parameter is used to configure the scoring formula that identifies the ideal Perimeter score of found blobs.

ClosedPerimeter Scoring Formula

  • The FindBlobs Perimeter score is computed by using the following formula:

    Perimeter Score = [(Range + Perimeter) - BlobPerimeterVal]/Range * WeightVal

    • BlobPerimeterVal = the referenced blob's output Perimeter value
    • WeightVal = Weight/(sum of all weight values) * 100

Perimeter

The ideal blob perimeter (0 to 100000; default = 1000).

Range

The blob perimeter tolerance, in similarity scoring (0 to 100000; default = 10000).

Weight

The relative importance of blob perimeter, in similarity scoring (0 to 100; default = 50).

Spread

This parameter is used to configure the scoring formula that identifies the ideal Spread score of found blobs.

ClosedSpread Scoring Formula

  • The FindBlobs Spread score is computed by using the following formula:

    Spread Score = [(Range + Spread) - BlobSpreadVal]/Range * WeightVal

    • BlobSpreadVal = the referenced blob's output Spread value
    • WeightVal = Weight/(sum of all weight values) * 100

Spread

The ideal blob spread (0 to 900000; default = 1).

Range

The blob spread tolerance, in similarity scoring (0 to 900000; default = 2).

Weight

The relative importance of blob spread, in similarity scoring (0 to 100; default = 50).

Show

Specifies the display mode for FindBlobs graphical overlays on top of the image.

0 = hide all (default)

All graphics will be hidden, except when the cell containing the FindBlobs function is highlighted in the spreadsheet.

1 = result graphics only

Blob outlines will be displayed at all times.

FindBlobs Outputs

Returns

A Blobs data structure containing the matching blobs sorted by score, or #ERR if any of the input parameters are invalid.

Results

When FindBlobs is initially inserted into a cell, a Closedresult table is created in the spreadsheet.

Note: If the value of the Number to Find parameter is greater than zero, FindBlobs 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.

FindBlobs Vision Data Access Functions

The following Vision Data Access functions are automatically inserted into the spreadsheet to create the FindBlobs Blobs data structure result table:

Spreadsheet Name

Function Name

Description

Row

GetRow(Blobs, Blob Index)

Returns the y-coordinate (Row) of the referenced blob's center of mass (centroid).

ClosedEXAMPLE

Col

GetCol(Blobs, Blob Index)

Returns the x-coordinate (Column) of the referenced blob's center of mass (centroid).

ClosedEXAMPLE

Angle

GetAngle(Blobs, Blob Index)

Returns the angle of the referenced blob's center of mass, relative to the center of the ROI.

ClosedEXAMPLE

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.

Area

GetArea(Blobs, Blob Index)

Returns the area of the referenced blob (measured in pixels).

ClosedEXAMPLE

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.

ClosedEXAMPLE

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.

ClosedEXAMPLE

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.

ClosedEXAMPLE

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, please refer to the BoundingRectangle function. For more information, 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, please refer to the BoundingRectangle function.

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, please refer to the BoundingRectangle function.

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, please refer to the BoundingRectangle function.

FindBlobs Example

The FindBlobs function is used to filter and sort the blobs returned in a Blobs data structure. This example will help to illustrate how the FindBlobs parameter settings can be set to examine a list of blobs, and only return those blobs that match a specified ideal.

A FindBlobs function was inserted into the spreadsheet, which will automatically launch the ClosedFindBlobs property sheet. For the purposes of this example, the blobs are being examined and the parameters are being set to return only those blobs with 0 holes in them, regardless of any other criteria.

Based upon these requirements, the FindBlobs 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 Find: This parameter was set to 1, because the image contains only one such blob. Had this parameter been set higher, the cells below the one returned blob would have been #ERR.
  • Accept Thresh: The default setting was used. By using this setting in situations where there is less certainty in regards to the blobs, the lower the threshold guarantees that more blobs will be returned, though their similarity to the ideal decreases.

    Because the blobs are being examined to return only blobs with 0 holes in them, the only parameter that will need to be configured is the Holes parameter. All the other blob properties parameters will be left at their default settings, except for their Weight settings, which will be set to 0.

  • Holes: In this instance the Holes Number value is set to 0, while the Range value is reduced to 0 and the Weight is set to 100. This guarantees that only those blobs in the Blobs data structure with 0 will be returned in the resulting FindBlobs Blobs data structure and Closedresult data table.

For more information, see Blobs, DetectBlobs, ExtractBlobs, and SortBlobs.