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.
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 runtime lighting variations and accurately detect flaws. However, it does not have the ability to compensate for possible variations, as the DetectFlaw, FlexFlawModel and TrainFlawModel functions can, so it can not adjust for process variations in a part. Therefore, 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. If the part will have process variations, the other Flaw Detection functions should be able to account for the variations. For more information, see Flaw Detection.
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. The images may be loaded using the Record/Playback Options dialog. For more information, see Record/Playback Options Dialog.
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. For more information, see Fixture.
- 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. For more information, see Mask.
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.
SurfaceFlawInputs
Syntax: SurfaceFlaw(Image,Fixture.Row,Fixture.Column,Fixture.Theta,Region.X,Region.Y,Region.High,Region.Wide,Region.Angle,Region.Curve,External Region,Straighten Images,Sampling Factor,Automatic Smoothing,Smoothing Factor,Detection Type,Detection Size,Detection Axis,Calculate Flaw Data,Calculate Flaw Shapes,Minimum Flaw Area,Maximum Flaw Area,Minimum Contrast,Timeout,Display Image,Display Row,Display Col,Show)
Parameter | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Specifies a reference to a spreadsheet cell that contains an Image data structure; by default, this parameter references A0, the cell containing the AcquireImage Image data structure. This parameter can also reference other Image data structures, such as those returned by the Vision Tool Image functions or Coordinate Transforms Functions. Note:
|
|||||||||||||
Defines the Region of Interest (ROI) relative to a Fixture input or the output of a Vision Tool 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. For more information, see Fixture and Vision Tools Functions. Note: The default setting is (0,0,0), the top leftmost
corner of the image.
|
|||||||||||||
The Region of Interest (ROI) specifies the region of the image that undergoes analysis and creates a rectangular image region that can be transformed and rotated. For more information, see Interactive Graphics Mode. Tip: With this parameter
selected, you can press the Maximize
Region button on the property sheet's toolbar to maximize the region and 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 Tool function or Controls 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.
|
|||||||||||||
Specifies a reference to a spreadsheet cell that contains a Controls function or a Mask data structure, output by a Mask function. When this parameter is used, the function will ignore the Region and Fixture settings and inspects the image area specified by the referenced region. For more information, see Controls Functions and Mask. 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.
|
|||||||||||||
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:
|
|||||||||||||
Specifies the amount by which to sample (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. The parameter range is:
|
|||||||||||||
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 is Off 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.
|
|||||||||||||
Specifies the factor (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. The parameter range is:
Note: This parameter is disabled if the Automatic Smoothing parameter is enabled.
|
|||||||||||||
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.
|
|||||||||||||
Specifies the detection neighborhood size (default = 1), in pixels. This parameter is used to construct the processing neighborhood, or kernel, for use with the Detection Type parameter. The parameter range is:
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.
|
|||||||||||||
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.
|
|||||||||||||
Specifies whether or not the function will calculate the area, intensity and bounding box for each detected flaw. Note: Disabling this parameter will decrease the function's execution time. When this parameter is disabled, the internal blob analysis will not be performed. This will cause the function to only return the total area of "flaw " pixels, and no graphical information will denote where the flaws are located in the image. The function's auto-generated results table will return #ERR for the individual results; to extract the data, use the GetTotalFlawArea Vision Data Access function, which returns the total area of all of the flaws, combined. For more information, see Flaw Detection.
|
|||||||||||||
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.
|
|||||||||||||
Specifies the minimum size (default = 30), in pixels, of the flaws to detect. The parameter range is:
For example, when connected to the In-Sight 7802 vision system, the parameter range is 0 to 1,920,000 (1600x1200). |
|||||||||||||
Specifies the maximum size (default = 99999), in pixels, of the flaws to detect. A value of 0 specifies that there is no maximum size. The parameter range is:
For example, when connected to the In-Sight 7802 vision system, the parameter range is 0 to 1,920,000 (1600x1200). |
|||||||||||||
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. |
|||||||||||||
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 disables the setting and a timeout is not applied. |
|||||||||||||
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.
|
|||||||||||||
Specifies the Row coordinate (default = 0) where the display image will be displayed, relative to the upper left-hand corner. Note:
|
|||||||||||||
Specifies the Column coordinate (default = 0) where the display image will be displayed, relative to the upper left-hand corner. Note:
|
|||||||||||||
Specifies the display mode for SurfaceFlaw graphical overlays on top of the image.
|
SurfaceFlawOutputs
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. 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. For more information, see Flaw Detection.
|
SurfaceFlawVision Data Access Functions
The following Vision Data Access functions are automatically inserted into the spreadsheet to create the result table. For more information, see Flaw Detection.
Spreadsheet Name | Function Name | Description |
---|---|---|
Total Flaw Size | GetTotalFlawArea(SurfaceFlaw) | Returns the total area of all of the flaws, combined. |
Index | N/A | Returns the indexed flaws, sorted from largest to smallest in area. |
Row | GetRow(SurfaceFlaw, Index) | Returns the row coordinate, in pixels, of the bounding box surrounding the flaw. |
Col | GetCol(SurfaceFlaw, Index) | Returns the column coordinate, in pixels, of the bounding box surrounding the flaw. |
High | GetHigh(SurfaceFlaw, Index) | Returns height value, in pixels, of the bounding box surrounding the flaw. |
Wide | GetWide(SurfaceFlaw, Index) | Returns the width value, in pixels, of the bounding box surrounding the flaw. |
Area |
GetArea(SurfaceFlaw, Index) |
Returns the area, in pixels, of the flaw. |
Perimeter |
GetPerimeter(SurfaceFlaw, Index) |
Returns the perimeter, in pixels, of the flaw. |
Intensity |
GetAverageIntensity(SurfaceFlaw, Index) |
Returns the average pixel intensity value of the flaw. |
Roundedness |
GetRoundedness(SurfaceFlaw, Index) | Returns the roundedness, in pixels, of the flaw. |