SurfaceFlaw
The SurfaceFlaw function is used to detect local intensity variations, which may indicate a flaw, such as a scratch, nick or tear on the object/ part being inspected.
Overview
The SurfaceFlaw function is designed to detect areas of local intensity and color variations which are flaws in the production process. The function uses two different types of internal filtering operations (Fast, which is used to detect edge-like flaws, or Light Flaws, Dark Flaws or Light and Dark Flaws, which are used to detect blob-like flaws) to first highlight edges and areas with sudden color or greyscale variations, before establishing a threshold and applying blob analysis to determine whether or not flaws are present.
SurfaceFlaw is a stand-alone function, and does not require the use of a model, simplifying its setup and improving its execution time. Due to not incorporating a model, the function is able to account for run-time lighting variations and accurately detect flaws. SurfaceFlaw is best suited to applications where a part should have a uniform area to be inspected, such that any sudden change in intensity will be classified as a defect.
Configuring the SurfaceFlaw function
Setting up the SurfaceFlaw function involves establishing the thresholds that will be used to determine whether or not a flaw exists. Before beginning, collect a database of images of the part to be inspected which contain images of the part in its error-free state, as well as those illustrating common error cases.
To begin, first load an image of the part in its error-free state. Insert the SurfaceFlaw function into the Spreadsheet, and adjust its Region to enclose the area of the image that will be inspected. When configuring the Region, ensure that it does not contain extraneous features, such as labels, the edges of characters or logos, for example. If the inspection will include an edge of a part, the Region must be positioned parallel to the edge (the same applies to circular-shaped Regions, with the circular region arc being parallel to the edge of the part), but not over the edge.
- If the part will exhibit motion, use a fixture to ensure the Region moves accordingly with the part.
- If the part contains areas that should be excluded from inspection, such as labels or alpha-numeric characters, use a Mask data structure output by the Mask function to remove them. This allows the function to only inspect specified areas within an image.
Ensure that the function's parameters are configured such that the function does not identify any flaws. The SurfaceFlaw function contains a Display Image parameter, which provides visual feedback on how parameter adjustments affect the function. Set the Display Image parameter to Flaw Candidates to begin, so that any detected flaws are enclosed within a red bounding box.
When adjusting the parameters, try adjusting the Sampling Factor and Smoothing Factor parameters. Increase the Sampling parameter when trying to detect low gradient flaws, or large flaws with low contrast. Increase the Smoothing Factor parameter to help get rid of small, false defects.
After adjusting those parameters, use the different options of the Detection Type, Detection Size and Detection Axis parameters. The function has two types of flaw detection operations: edge-like flaws or blob-like flaws. When the Detection Type parameter is set to Fast, the function performs an Erosion-Dilation filter to detect edge-like flaws at the edge of "area"-type flaws. Thus, the function will report the size of the flaw as the perimeter of the flaw's bounding box, versus the overall area of the flaw. This setting is useful in detecting flaws such as scratches or tears.
The Light Flaws, Dark Flaws or Light and Dark Flaws Detection Type options use combinations of Bottom-Hat and Top-Hat filters to detect blob-like flaws. This allows the function to detect flaws based on their pixel size. These options are useful in detecting flaws based on their area, such as splotches, smears or stains. However, these three Detection Type options generally require more processing time.
For most applications that require the Detection Type parameter be set to Fast, a Detection Size of 1 is typically appropriate. For applications that require Light Flaws, Dark Flaws or Light and Dark Flaws, the Detection Size parameter must be set to a size that is greater than the radius of the flaw to be detected.
Finally, adjust the Minimum Flaw Area, Maximum Flaw Area and Minimum Contrast parameters to ensure that the flaws are being properly detected and highlighted, respectively.
Once the function is correctly inspecting the part in its error-free state, load an image of the part containing a flaw. Again, go through the process of adjusting the parameters until the function correctly identifies the desired flaws. After the flaws have been identified, re-load an image of the part in its error-free state and ensure it is still being correctly inspected as not containing flaws. The function will be ready for run-time inspections once all of the database images have been properly configured.
SurfaceFlaw Inputs
Parameter | Description | ||||||||||||
Image |
This parameter must reference a spreadsheet cell that contains an Image data structure; by default, this parameter references A0, the cell containing the AcquireImage data structure. This parameter can also reference other Image data structures, such as those returned by the Image Vision Data Access Functions or Coordinate Transforms Functions. Note:
|
||||||||||||
Fixture |
Defines the Region of Interest (ROI) relative to a Fixture input or the output of a Vision Tools function's image coordinate system. Setting the ROI relative to a Fixture ensures that if the Fixture is rotated or translated, the ROI will be rotated or translated in relation to the Fixture. The default setting is (0,0,0), the top leftmost corner of the image.
|
||||||||||||
Region |
Also known as the Region of Interest (ROI), specifies the region of the image that undergoes analysis; creates an Interactive Graphics Mode that can be transformed and rotated. With this parameter selected, by pressing the Maximize Region button on the property sheet's Job Edit toolbar, the region will automatically be stretched to cover the entire image. Note: Use the External Region parameter instead of setting Cell References to the region coordinates if attempting to define the ROI relative to the output of another Vision Tools function or Controls Functions function. The External Region parameter will properly account for fixture movement, while the cell references may not function correctly and may cause any functions that reference it to result in #ERR.
|
||||||||||||
Note: The Fixture and Region parameters must be defined
within the bounds of the image; otherwise, the function will return #ERR.
|
|||||||||||||
External Region |
Specifies Cell References to a spreadsheet cell that contains a Controls Functions Note:
If this parameter has been set as a reference to an external region, to use the function's internal Region, this parameter must be manually set to zero by entering the value 0 in place of the cell reference. Otherwise, the function will continue to reference the external region. |
||||||||||||
Straighten Images |
Specifies whether or not the function will straighten a curved or angled region of interest (ROI), prior to further image processing. Enabling this parameter is helpful in situations where flaws are only being detected along a particular axis (X or Y); the detection kernel always processes along the image's X and Y axis, independent of the ROI orientation or shape. In order to detect a flaw along a straight edge that is "diagonal" in the image, the image should first be straightened. Note: This parameter is necessary if the internal Region or the External Region parameters have an angle or are curved.
|
||||||||||||
Sampling Factor |
Specifies the amount by which to sample (1 to 99999; default = 1) the input image, thus reducing its resolution. Sampling is used to help reduce the function's execution time, however, at the expense of accuracy. Sub-sampling the image is helpful in instances where the contrast of the flaws is low and they gradually move; sub-sampling brings the pixels closer together so the transitions are shorter and steeper. When determining the proper sampling value, a value of 1 denotes no sampling, i.e. that the input image will be used at full resolution. Higher values denote less resolution and accuracy, but faster execution times. |
||||||||||||
Automatic Smoothing |
Specifies whether or not the function will determine the optimal smoothing factor by which to smooth the image. Allowing the function to select the optimal smoothing factor generally enables better performance. Note: The Automatic Smoothing parameter checkbox is disabled by default. To enable the parameter, the Sampling Factor parameter must be set to a value greater than 1. If the Sampling Factor parameter is set to a value greater than 1 and Automatic Smoothing is not desired, turn off the parameter and set the appropriate value using the Smoothing Factor parameter, instead.
|
||||||||||||
Smoothing Factor |
Specifies the factor (0 to 99999; default = 0) by which to smooth the image. When determining the optimal value, begin with a similar value as specified in the Sampling Factor parameter. To specify no smoothing, set the value to 0. Note: The Smoothing Factor parameter is disabled if the Automatic Smoothing parameter is enabled and On.
|
||||||||||||
Detection Type |
Specifies the type of image processing to apply to the image to determine if flaws are present. Note: If Light Flaws, Dark Flaws or Light and Dark Flaws is the selected type of image processing, the Detection Size parameter must be set to the size of the largest flaw to be detected.
|
||||||||||||
Detection Size |
Specifies the detection neighborhood size (1 to 99999; default = 1), in pixels. This parameter is used to construct the processing neighborhood, or kernel, for use with the Detection Type parameter. Note: For all the Detection Type operations other than Fast, the size value must be set to a value that is at least as large as the length or width of the flaws to be detected.
|
||||||||||||
Detection Axis |
Specifies the axis in which to detect potential flaws. This parameter also determines the height of the kernel. For example, if this parameter is set to X and Y, with a Detection Size of 1, the kernel will be a 3 x 3 grid. If this parameter were set to X, with a Detection Size of 1, the kernel will be 1 x 3, in the X direction.
|
||||||||||||
Calculate Flaw Data |
Specifies whether or not the function will calculate the area, intensity and bounding box for each detected flaw. Note:
|
||||||||||||
Calculate Flaw Shapes |
Specifies whether or not the function will also calculate the perimeter and roundedness of each flaw. Roundedness is a unit-less number that represents how circular a flaw is; a perfect circle has a roundedness value of 1.0. Elongated flaws will have values greater than 1, with values larger than that representing even further elongation. Point-like flaws may have values closer to 0. Note: The Calculate Flaw Data parameter must be enabled to activate this parameter.
|
||||||||||||
Minimum Flaw Area |
Specifies the minimum size (1 to 99999; default = 30), in pixels, of the flaws to detect. |
||||||||||||
Maximum Flaw Area |
Specifies the maximum size (1 to 99999; default = 99999), in pixels, of the flaws to detect. A value of 0 specifies that there is no maximum size. |
||||||||||||
Minimum Contrast |
Specifies the intensity threshold (1 to 255; default = 20) used to detect flaws. For a flaw to be detected, its intensity must differ by this value from the background. |
||||||||||||
Timeout (ms) |
Specifies the amount of time, in milliseconds (0 to 30000; default = 0/No Timeout), that the function will search for flaws before execution is halted and #ERR is returned. Setting the value to 0 will disable the setting and a timeout will not be applied. |
||||||||||||
Display Image |
Specifies the output image to display. Note: This image is for display purposes only, and may not be used as an input to another function.
|
||||||||||||
Display X |
Specifies the x-coordinate (default = 0) where the display image will be displayed, relative to the upper left-hand corner. This parameter is enabled under the following conditions:
|
||||||||||||
Display Y |
Specifies the y-coordinate (default = 0) where the display image will be displayed, relative to the upper left-hand corner. This parameter is enabled under the following conditions:
|
||||||||||||
Show |
Specifies the display mode for SurfaceFlaw graphical overlays on top of the image.
|
SurfaceFlaw Outputs
Returns |
A SurfaceFlaw data structure containing the display image data and detected flaws; or #ERR if any of the input parameters are invalid. |
|||||||||||||||||||||||||||||||||
Results |
When the function is initially inserted into a cell, a results table is created in the spreadsheet using the following Flaw Detection Vision Data Access Functions: Note: If the Calculate Flaw Data parameter is disabled, the function will only return the total area of all of the detected flaws; use the GetTotalFlawArea Vision Data Access function, which returns the total area of all of the flaws, combined.
|