# InspectBead

The InspectBead 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. is used to identify positional, width, or coverage defects in a bead. The InspectBead tool has parameters to control the bead analysis criteria and measurement rules. The tool compares the bead characteristics found in the currently acquired image against the bead analysis criteria. For more information on the TrainBead function, see TrainBead.

Note:

- The TrainBead and InspectBead functions do not support color images. If you load a color image, the functions automatically convert it to a greyscale image.
- For more information about how to use the TrainBead and InspectBead functions, see How to use TrainBead and InspectBead Tools.

## InspectBead Inputs

### General Tab

Syntax: InspectBead(Image,Bead Find,Edit Inspection Areas,Bead Edge Position Tolerance (%),Contrast Threshold,Defect Limits,Show Graphics)

Parameter | Description
--- | ---
Image | This argument must reference a spreadsheet cell that contains a valid Image data structure. By default, the cell references A0, containing the Image data structure returned by the AcquireImage function.
TrainBead | Specifies a reference to a spreadsheet cell that contains a Bead data structure output by the TrainBead function. Note: The TrainBead function must be trained or the InspectBead function returns #ERR. If a TrainBead function is retrained, any linked InspectBead function parameters, the masked region(s), the fill edge region(s) and any previous editing set in the Edit Inspection Areas are reset.
Edit Inspection Areas | Click this button to enter Interactive Graphics Mode to edit areas that can be masked out from the inspection or allow fill edges. You can do the following: Click and drag to draw a box. Any sections of the bead inside the box get masked. Any defects inside masked areas are ignored. Right-click for more options. You can draw masks, draw fill edges, or clear masks and fill edges.
Bead Edge Position Tolerance (%) | Specifies the maximum amount (1 to 1000; default = 50) an edge can deviate from the trained edge position as a percentage of the average bead width at that location. Bead edges that are outside of this tolerance range are not going to be found. Example: An edge must be found between the trained bead path (in green) and the Position Tolerance Boundary (in cyan). The Bead Edge Position Tolerance (%) value is measured from the trained edge position on either side of the expected edge. The average bead width is considered 100%. The trained bead path is in the middle of the bead, which is 50% deviated from the trained edge position. If the position tolerance is less than 50%, two dashed lines on either side of the bead path appear. If the position tolerance is 50% or greater, only one single dashed line is displayed on either side of the bead path.
Contrast Threshold | Specifies the minimum valid edge contrast value (1 to 255; default = 10). Bead edges with contrast values below this threshold are identified as defects.
Defect Limits | Specifies how defects are defined and whether a particular type of defect needs to be detected.
Bead Width Min | Indicates whether the minimum width defect detection is enabled. This parameter is used to inspect the bead for sections that are too narrow.
Bead Width Min (%) | Specifies the minimum valid bead width (1 to 99; default = 50) in percentage compared to the corresponding section of the bead when it was trained. Bead edges found below this limit are identified as defects. For example, a Minimum Bead Width of 50% allows each section of the bead to be half as wide as it was on the trained bead.
Bead Width Max | Indicates whether the maximum width defect detection is enabled. This parameter is used to inspect the bead for sections that are too wide.
Bead Width Max (%) | Specifies the maximum valid bead width (101 - 999; default = 150) in percentage compared to the corresponding section of the bead when it was trained. Bead edges found above this limit are identified as defects. For example, a Maximum Bead Width of 200% allows each section of the bead to be twice as wide as it was on the trained bead.
Bead Coverage Min | Indicates whether the minimum coverage defect detection is enabled. This parameter is used to inspect the bead for sections that contain too few light pixels (for light-on-dark beads) or dark pixels (for dark-on-light beads) compared to the corresponding section of the bead that was trained.
Bead Coverage Min (%) | Specifies the minimum bead coverage (1 to 99; default = 50) allowed at each section of the bead compared to the corresponding section of the bead that was trained. Use a lower value to allow beads that are much lighter (for dark-on-light beads) or much darker (for light-on-dark beads) than the trained bead.
Bead Coverage Max | Indicates whether the maximum coverage defect detection is enabled. This parameter is used to inspect the bead for sections that contain too many light pixels (for light-on-dark beads) or dark pixels (for dark-on-light beads) compared to the corresponding sections of the bead that was trained.
Bead Coverage Max (%) | Specifies the maximum bead coverage (101 to 999; default = 150) allowed at each section of the bead compared to the corresponding section of the bead that was trained. Use a higher value to allow beads that are much darker (for dark-on-light beads) or much lighter (for light-on-dark beads) than the trained bead.
Bead Edge Step Max | Indicates whether the maximum step change defect detection is enabled. This parameter is used to detect protrusions or notches along the edges of the bead.
Bead Edge Step Max (%) | Specifies the maximum position offset (1 to 100; default = 30) allowed for a bead edge compared to neighboring edges. Use a higher value to increase tolerance for beads with coarse or uneven edges. Use a lower value for beads with smoother edges.
Defect Length Min (Calipers) | Specifies the smallest defect size (1 to 10 adjacent calipers; default = 3) that gets to be reported as a defect in the inspection results. A value of 1 includes all defects. A value of 10 reports only defects comprised of 10 or more adjacent calipers.
Show Graphics | Specifies which InspectBead graphical overlays are drawn on top of the image.
Bead Path | Displays the trained bead path (in green) used for finding defects. It is the path from the referenced TrainBead function.
Bead Edges | Displays the found edges for the bead path in yellow. Example:
Position Tolerance Boundary | Displays the boundaries (in cyan dashed lines) for finding bead edges. The tool does not detect edges outside of this boundary, resulting in defects. If the position tolerance is less than 50, two dashed lines on either side of the bead path appear. If the position tolerance is 50 or greater, there a single dashed line on either side of the bead path appears. Example:
Mask and Fill Edge Areas | Displays masked and fill edges areas along the bead path. Masked regions appear in black. Fill edge regions appear in cyan. Fill Edges allow one side of the bead to go undetected in that area. The masked area is ignored in future inspections and no defect in masked area is reported. Example:
Bead Width Defects | Displays the bounding region for bead width defects (in red).
Bead Coverage Defects | Displays the bounding region for bead coverage defects (in red).
Bead Edge Step Defects | Displays the bounding region for bead edge step defects (in red).
Missing Edge Defects | Displays the bounding region for missing edge defects (in red).

### Defects Tab

The Defects tab displays the overall results for bead inspection, and is divided into two sections: statistics and defect list.

#### Statistics

The statistics contain the following data and updates automatically after each image is loaded or after a change is made to the InspectBead function.

- Defect Count: Displays the total number of defects found in the bead.
- Caliper Count: Displays the total number of calipers in the bead path.
- Contrast (First Edge): Displays the minimum, maximum, and average contrast value along the first edge of the bead.
- Contrast (Second Edge): Displays the minimum, maximum, and average contrast value along the second edge of the bead.
- Bead Width: Displays the minimum, maximum, and average width as a percentage of the bead.
- Bead Coverage: Displays the bead coverage as a percentage of the bead.
- Bead Position Shift (First Edge): Displays the minimum, maximum, and average deviation of the first edge as a percentage of the bead width.
- Bead Position Shift (Second Edge): Displays the minimum, maximum and average deviation of the second edge as a percentage of the bead width.
- Bead Edge Step Max (First Edge): Displays the maximum step change as a percentage of the bead width along the first edge of the bead.
- Bead Edge Step Max (Second Edge): Displays the maximum step change as a percentage of the bead width along the second edge of the bead.

#### Defect Results Table

For each defect, the defect table displays the following:

Parameter | Description
--- | ---
Index | Displays the defect index number.
Classification | Displays defect type. Defect Types: Too Narrow Too Wide Underfill Overfill Missing First Edge Missing Second Edge Missing Both Edges Step Change No Bead Found

Parameter | Displays the InspectBead parameter that is associated with the defect.
Actual | Displays the actual value reported by the InspectBead function.
Expected | Displays the allowed value range specified by the InspectBead parameters.
Fix (button) | Provides the following tuning options to remove false defects from the defect results table:
Update {Parameter} | Updates the corresponding parameters associated with different defect types. If this option is selected, the related minimum or maximum parameters in Defect Limits are updated with the actual value, and the defects are removed from the defect results table. Defect Types and Related Parameters
Defect Types | Related Parameters | Description
--- | --- | ---
Too Narrow | Bead Width Min (%) | Used to inspect the bead for sections that are too narrow.
Too Wide | Bead Width Max (%) | Used to inspect the bead for sections that are too wide.
Underfill | Bead Coverage Min (%) | Used to inspect underfill defects where too little material is applied to a section of the bead.
Overfill | Bead Coverage Max (%) | Used to inspect overfill defects where too much material is applied to a section of the bead.
Step Change | Bead Edge Step Max (%) | Used to inspect protrusions or notches along the edges of the bead. Select a higher Bead Edge Step Max value to increase tolerance for beads with coarse or uneven edges. Use a lower bead step value for beads with smoother edges
Missing First Edge Missing Second Edge Missing Both Edges | Contrast Threshold | Used to inspect missing edges defects. Bead edges with contrast values below the Contrast Threshold are identified as defects.
Bead Edge Position Tolerance (%) | Used to inspect bead edges position changes. Bead edges that are outside of the Bead Edge Position Tolerance are not be found.
Allow Fill Edges | Creates a Fill Edge within a defect that contains a missing edge. Fill Edges allow one side of the bead to go undetected in that area. Note: Works only for Missing First Edge and Missing Second Edge defect types. This option is not available if both edges are missing.
Mask/Ignore | Masks the defect area from inspection. Future inspections ignore the masked area. No defect in masked area are reported.

### Editing the Inspection Areas

Click Edit Fill and Mask Areas to edit the inspection areas.

You have the following options:

- Area Select Adds Mask: Mask the selected area.

- Area Select Adds Fill: Fill the selected area.

- Area Select Clears Mask/Fill: Clear the masking or filling of the selected area.

## InspectBead Outputs

Returns | A Bead data structure containing the information about detected beads in the image, or #ERR if any of the input parameters are invalid.
Results | When InspectBead is initially inserted into a cell, a results table is created in the spreadsheet. For example, this is the default InspectBead results table: Note: The Vision Data Access function returns #ERR if no defect is found. The Vision Data Access function returns a single defect with Type integer value 256 if no bead path is detected.