# FindCircleDefects

Converts each pixel within an annular (ring-like) region in an input image to black or white based on a user-set threshold, with white indicating non-circular or non-radial features. Define and position the annulus over the image, and choose whether the function Functions are tools that are available in Spreadsheet for processing and analyzing acquisitions or other results. You can add functions to your Spreadsheet job to create tool chains and produce results for specific applications. calculates pixel gradient in either a circular or radial direction. Values equal to or exceeding the threshold level are displayed as white pixels in the black-and-white output image.

Inputs

Parameter | Description
Image | This parameter must reference a spreadsheet cell that contains an Image data structure. By default, this parameter references cell A0 , containing the AcquireImage function. This parameter can also reference other Image data structures, such as those returned by the Image Vision Data Access functions or Coordinate Transforms Functions.
Fixture A fixture is a coordinate location on the image that keeps the tool in the place determined by the fixture. | Defines the Region of Interest (ROI) relative to a Fixture input or the output of the image coordinate system for the Vision Tools function. Setting the ROI relative to a Fixture ensures that if the Fixture is rotated or translated, the ROI is rotated or translated in relation to the Fixture. Note: 2D projections use real world units but fixturing with 2D tools requires input in pixel values. When using a 2D projection from a 3D point cloud A point cloud is a 3D structure that consists of the data points collected by a 3D vision system during acquisition. as a Fixture, convert the real world units to pixel values using the TransWorldToPixel function. Note: Angles must be multiplied by -1, due to image space differences. The default setting is (0,0,0), the top leftmost corner of the image.
X | The X-offset, in image coordinates.
Y | The Y-offset, in image coordinates.
Theta | The rotation from the image X-axis, in the image coordinate system. (+/-360 degrees clockwise)
Annulus | Also known as the Region of Interest (ROI), it specifies the region of the image that undergoes analysis. It creates an annular image region that can be translated and rotated. With this parameter selected, by pressing the Maximize Region button on the toolbar of the property sheet, the region is automatically stretched to cover the entire image.
X | The X-offset of the origin, in fixture coordinates.
Y | The Y-offset of the origin, in fixture coordinates.
Inner Radius | The size of the inner radius.
Outer Radius | The size of the outer radius.
Note: The Fixture and Annulus parameters must be defined within the bounds of the image. Otherwise, the function returns #ERR.
Defect Type | Specifies the type of defect to which the function is sensitive: circular or radial. Pixels that vary in greyscale value from surrounding pixels indicate possible defects.
0 = Non-circular features (default) | Specifies calculating pixel gradient in the annulus in a circular direction to detect deviations from a circle.
1 = Non-radial features | Specifies calculating pixel gradient in the annulus in a radial direction to detect deviations from radial features.
Deviation | Specifies the degree of tolerance in the defect detection.
0 = OFF (default) | Specifies that the object is circular and centered in the annulus, a less tolerant setting.
1 = ON | Specifies that the object can be oval or off-centered in the annulus, a more tolerant setting.
Accept Thresh | Specifies the defect threshold, in greyscale value. (0–255; default = 30)
Show | Specifies which graphical overlays are displayed on top of the image.
0 = hide all (default) | The available graphics items are hidden, except when the cell containing the FindCircleDefects function is highlighted in the spreadsheet.
1 = result graphics only | The processed image is displayed at all times.
2 = input graphics only | The graphics items associated with the input image region are displayed at all times.

Outputs

Returns | An Image data structure that stores the black-and-white ("binary") image, or #ERR if any of the input parameters are invalid.
Results | When FindCircleDefects is initially inserted into a cell, a result table is created in the spreadsheet using the following Image Vision Data Access functions
Label | Function | Description
DarkCount | GetDarkPixelCount(Image) | Returns the number of pixels below the defect threshold. The pixels are displayed as black.
BrightCount | GetBrightPixelCount(Image) | Returns the number of pixels equal to or above the defect threshold. The pixels are displayed as white.
Additional data elements can be accessed using the following Image Vision Data Access functions:
Area | GetArea(Image) | Returns the area of the region.

## FindCircleDefects Example

In this example, the synthetic circular (left) and radial (right) objects shown below are used to demonstrate the functionality of the FindCircleDefect. Both objects are medium-grey in color and feature thick, dark inner and outer borders.

1. Insert the function into the In-Sight Spreadsheet spreadsheet.

2. Define the annulus by double-clicking on Annulus in the property sheet, which disappears to reveal the red annulus overlaid on the image.

3. Move or resize the annulus using the cursor.

4. Press the Enter key or double-click within the annulus to confirm the selection and return to the property sheet. The example shows images of the objects with their annuli.

5. Select a defect type (non-circular or non-radial).

6. Choose ON or OFF for the deviation tolerance.

7. Accept the default settings of the other parameters and click OK in the property sheet to complete the configuration for this example and apply the function to the input image.

Below are black-and-white output images of the circular object, with the function set to detect non-circular defects, the Accept Thresh parameter at the default value of 30 and the deviation tolerance at OFF (left) and ON (right). Notice how much stricter the OFF setting (left) is, marking pixels in the outer edge of the circular object as possible defects, even though they appear to be part of the smooth circular curve.

Below is a black-and-white output image of the same circular object with the function now set to detect non-radialdefects. The function marks the inner and outer edges of the outer border as possible radial defects.

Below are black-and-white output images of the radial object, with the function set to detect non-radialdefects, the Accept Thresh parameter at 70 and the deviation tolerance at OFF (left) and ON (right). Again, notice how much stricter the OFF setting (left) is, marking the outer edges of the radial features as possible defects.

Below is a black-and-white output image of the same radial object with the tool now set to detect non-circular defects. The function marks all radial features within the annulus as possible circular defects.

In a real-world application, you would next reference another tool to the output image, so that a decision could be made regarding the results.