# InspectEdgeWidth

Used to construct an edge model to perform advanced edge analysis on the edge pairs returned by an InspectEdge 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.. This data is used to detect edge pairs and analyze the distance between them.

## InspectEdgeWidth Overview

After inserting the function into the spreadsheet, a reference must be made to an Inspect data structure output by an InspectEdge function. Once the reference to the InspectEdge function has been established, the edge model is created by configuring the parameters of the InspectEdgeWidth function. The edge model involves defining the following:

- The direction in which to detect edges.
- The type of edge transition - white to black or vice-versa.
- The edge scoring criteria that will be used to filter unwanted edges.
- The line fit criteria that will be used to filter unwanted edges from the line fit.
- The tolerances for width variances, defects and/or gaps to be encountered.
- The tolerances for position variances, if detecting a bead path.

Once the edge model has been established, the function will compare edge candidates against the edge model and report deviations from the model.

Note: The InspectEdgeWidth function can be used in conjunction with an InspectEdgeInspectBeadPath and an InspectEdge function to determine width and position errors related to a bead path. The InspectEdge parameter of the InspectEdgeWidth function must reference the Inspect data structure output by the InspectEdge function, which references the InspectEdgeInspectBeadPath function.
Inputs

Parameter | Description
InspectEdge | Specifies a reference to a spreadsheet cell that contains a valid Inspect data structure returned by an InspectEdge function.
Find Edge Direction | Specifies the direction in which the function attempts to detect edges. Dark green arrows are added to graphically illustrate the direction in which the edge is detected. Fit lines are labeled graphically within the image, with the first fit line labeled 0, and the second fit line 1. Note: If the region of interest (ROI) of the referenced InspectEdge function is bent into a curve, the inspection is relative to the center of the curve. When the Find Edge Direction parameter is set to Left-to-Right, it inspects towards the center of the curve, and when set to Right-to-Left, it inspects away from the center of the curve.
0 = Left-to-Right | The function attempts to detect edges from the left of the ROI to the right. Example
1 = Right-to-Left | The function attempts to detect edges from the right of the ROI to the left. Example
3 = Center Outward (default) | The function attempts to detect edges from the center of the ROI to the upper and lower bounds of the ROI (the order of the found edges is in the opposite direction of the "X" arrow on the ROI). Example
2 = Outside In | The function attempts to detect edges from the upper and lower bounds of the ROI to the center of the ROI (the order of the found edges is in the opposite direction of the "X" arrow on the ROI). Example
Edge: First | Specifies the contrast transition of the first edge to be detected, as determined by the Find Edge Direction parameter.
1 = Black-to-White | The edge transitions from black pixels to white pixels.
2 = White-to-Black (default) | The edge transitions from white pixels to black pixels.
3 = Either | The edge can transition from either black-to-white, or white-to-black, and the function determines the proper transition. Specifying the transition improves the performance of the function.
Edge: Second | Specifies the contrast transition of the second edge to be detected, as determined by the Find Edge Direction parameter.
1 = Black-to-White (default) | The edge transitions from black pixels to white pixels.
2 = White-to-Black | The edge transitions from white pixels to black pixels.
3 = Either | The edge can transition from either black-to-white, or white-to-black, and the function determines the proper transition. Specifying the transition improves the performance of the function.
Edge Scoring | Specifies the edge scoring mode used to determine whether or not an edge meets the established criteria.
Score Threshold | Specifies a scoring threshold to filter out edges with scores (1 to 100; default = 10) lower than this value.
Edge Rules | Specifies the type of edge that is most important when calculating the score.
1 = First | The first edge detected receives the highest consideration.
2 = Strongest | The edge with the strongest contrast transition receives the highest consideration.
3 = First Strongest | The first edge detected, with the strongest transition, receives the highest consideration.
4 = Edge Pair Size | The edge pair detected with the size closest to the Pair Size parameter receives the highest consideration.
5 = First Edge Pair Size | The first edge pair detected with the size closest to the Pair Size parameter receives the highest consideration.
6 = Strongest Edge Pair Size | The edge pair detected with the strongest transition and the size closest to the Pair Size parameter receives the highest consideration.
7 = First Strongest Edge Pair Size (default) | The first edge pair, with the strongest transition and the size closest to the Pair Size parameter, receives the highest consideration.
Contrast Upper Bound | Specifies the upper limit of the edge contrast transition (2 to 255; default = 255) to be considered an edge. Edges with an edge contrast transition above this value have the same highest score. Note: The Edge Rules parameter must be set to either Strongest, First Strongest, Strongest Edge Pair Size, or First Strongest Edge Pair Size to enable this parameter.
Pair Size | Specifies the edge pair size at which the highest score is achieved (valid range is 1 to 3 times the image width of the In-Sight vision system; default = 5). When this parameter is enabled, edge pairs detected above or below this value are scored proportionally to this value. For example, if the Pair Size is set to 10, and two edge pair candidates are detected, one with a value of 8 and another with 14, the edge pair with a value of 8 is selected because it is closer to the limit than the second edge pair. Note: The Edge Rules parameter must be set to either Strongest, First Strongest, Strongest Edge Pair Size, or First Strongest Edge Pair Size to enable this parameter.
Advanced Filter | Specifies how the function should construct the line fit.
Re-Score | Specifies that the edges are re-scored to select edges which are closer to the line fit.
0 = OFF (default) | The function does not re-score the edges to account for outliers.
1 = ON | The function re-scores the edges to account for outlier edges in its calculation.
Line Fit | Specifies the type of line fit to be constructed out of the detected edges.
1 = Straight Line Fit | The function creates straight line fit from the detected edges.
2 = Circle Line Fit | The function creates a circular line fit from the detected edges.
3 = Auto Fit (default) | The function automatically creates either a straight line or circular fit, based on the referenced Region.
Filter Outliers | Specifies that the function removes points from the Fit Line that are further than the distance specified in the Fit Distance Filter parameter.
0 = OFF (default) | The function does not account for outlier edges.
1 = ON | The function accounts for outlier edges in its calculation.
Fit Distance Filter | Specifies the distance, in pixels (valid ranges are 1 to 3 times the image width of the In-Sight vision system; default = 2), from which an edge must be from the original Fit Line to be utilized in a re-fit calculation. This setting is useful in helping to prevent defects from affecting the line fit. Filter Outliers must be ON to enable this setting.
Max Number of Defects/ Gaps | Specifies the maximum number of defects and gaps the function should expect to detect (1 to 4096; default = 5). This value is applied to Defects and Gaps individually. For example, when the setting is 5, the function expects to encounter a maximum of 5 Defects and 5 Gaps. This setting is used to construct the Vision Data Access Result Table in the spreadsheet.
Defects | Specifies the parameters for determining defects in the edge from the line fit.
Min Width | Specifies that any width distance, in pixels, between detected edge pairs less than this value is a defect. Valid ranges are 0.001 to 3 times the image width of the In-Sight vision system; default is 3 pixels.
Max Width | Specifies that any width distance, in pixels, between detected edge pairs greater than this value is a defect. Valid ranges are 0.001 to 3 times the image width of the In-Sight vision system; default is 3 times. Note: If this value is less than the Min Width parameter, the function results in a #ERR.
Size Enabled | Specifies whether or not the function accounts for size defects. Size defects account for width deviations along the length of the detected edge pairs. Note: When Size Enabled and Area Enabled are both ON, only defects which fail both conditions are displayed.
0 = OFF | The function does not account for size defects.
1 = ON (default) | The function accounts for size defects, based on the Min Size and Max Size parameter settings.
Min Size | Specifies the minimum defect size, in pixels. Continuous deviations from the line fit which are less than this value are not considered defects. Valid ranges are 0.001 to 3 times the image width of the In-Sight vision system; default is 3 pixels.
Max Size | Specifies the maximum defect size, in pixels. Continuous deviations from the line fit which are greater than this value are not considered defects. Valid ranges are 0.001 to 3 times the image width of the In-Sight vision system; default is 3 times.
Area Enabled | Specifies whether or not the function accounts for area defects. Area defects account for the length along the line fit and how far the defective edge is from the line fit. Note: When Size Enabled and Area Enabled are both ON, only defects which fail both conditions are displayed.
0 = OFF | The function does not account for area defects.
1 = ON (default) | The function accounts for area defects, based on the Min Area and Max Area parameter settings.
Min Area | Specifies the minimum area defect, in pixels (valid range is from 0.001 to 100000; default = 10). An area less than this value is not considered a defect.
Max Area | Specifies the maximum area defect, in pixels (valid range is from 0.001 to 1000000; default = 1000000). An area greater than this value is not considered a defect.
Sort Criteria | Specifies how the detected defects will be sorted.
By Size (default) | The function sorts detected defects by their size, from the largest to smallest.
By Area | The function sorts detected defects by their area, from the largest to smallest.
By Position | The function sorts detected defects by their Caliper index.
By Width | The function sorts detected defects by their width, from the largest to smallest.
Gaps | Specifies the parameters for determining gaps in the edge pairs.
Enabled | Specifies whether or not the function accounts for gaps in the found edge pairs.
0 = OFF | The function does not account for gaps.
1 = ON (default) | The function accounts for gaps, based on the other Gaps parameter settings.
Gap Minimum | Specifies the minimum gap, in pixels. Gaps less than this value are not considered to be gaps. Valid ranges are 0.001 to 3 times the image width of the In-Sight vision system; default is 3 pixels.
Gap Maximum | Specifies the maximum gap, in pixels; gaps greater than this value are not considered to be gaps. Valid ranges are 0.001 to 3 times the image width of the In-Sight vision system; default is 3 times.
Max Displacement | Specifies the maximum displacement, in pixels, from the center of the region to the center of the edge pair to be considered a gap. Valid ranges are 1 to 3 times the image width of the In-Sight vision system; default is 3 times.
Ignore Gap Ends | Specifies whether or not the function accounts for gaps detected at the beginning and end of the ROI.
0 = OFF | The function does not account for gaps detected at the beginning and end of the ROI.
1 = ON (default) | The function accounts for gaps detected at the beginning and end of the ROI.
Sort Criteria | Specifies how the detected gaps are sorted.
By Size (default) | The function sorts detected gaps by their size, from the largest to smallest.
By Position | The function sorts detected gaps by their Caliper index.
Position | Specifies the parameters for determining positional defects in the edge pairs. The parameters define a defect as a deviation from the center of a model path, output by an InspectEdgeInspectBeadPath function. These parameters should only be used when referencing an InspectEdge function that is referencing an InspectEdgeInspectBeadPath function.
Enabled | Specifies whether or not the function accounts for position defects in the found edge pairs.
0 = OFF (default) | The function does not account for position defects.
1 = ON | The function accounts for position defects, based on the other Position parameter settings.
Min Distance | Specifies the minimum positional displacement, in pixels, from the center of the detected bead path. Positional variations less than this value are not considered to be position defects. Valid ranges are 0.001 to 3 times the image width of the In-Sight vision system; default is 3 pixels.
Max Distance | Specifies the maximum positional displacement, in pixels, from the center of the detected bead path. Positional variations greater than this value are not considered to be position defects. Valid ranges are 0.001 to 3 times the image width of the In-Sight vision system; default is 3 times.
Size Enabled | Specifies whether or not the function accounts for size defects. Size defects account for width deviations along the length of the detected edge pairs. Note: When Size Enabled and Area Enabled are both ON, only defects which fail both conditions are displayed.
0 = OFF | The function does not account for size defects.
1 = ON (default) | The function accounts for size defects, based on the Min Size and Max Size parameter settings.
Min Size | Specifies the minimum defect size, in pixels; continuous deviations from the line fit which are less than this value are not considered defects. Valid ranges are 0.001 to 3 times the image width of the In-Sight vision system; default is 3 pixels.
Max Size | Specifies the maximum defect size, in pixels; continuous deviations from the line fit which are greater than this value are not considered defects. Valid ranges are 0.001 to 3 timesthe image width of the In-Sight vision system; default is 3 times.
Area Enabled | Specifies whether or not the function accounts for area defects. Area defects account for the length along the line fit and how far the defective edge is from the line fit. Note: When Size Enabled and Area Enabled are both ON, only defects which fail both conditions are displayed.
0 = OFF | The function does not account for area defects.
1 = ON (default) | The function accounts for area defects, based on the Min Area and Max Area parameter settings.
Min Area | Specifies the minimum area defect, in pixels. An area less than this value is not considered a defect. Valid range is from 0.001 to 100000; default is 10.
Max Area | Specifies the maximum area defect, in pixels. An area greater than this value is not considered a defect. Valid range is from 0.001 to 1000000; default is 1000000.
Sort Criteria | Specifies how the detected defects are sorted.
By Size (default) | The function sorts detected defects by their size, from the largest to smallest.
By Area | The function sorts detected defects by their area, from the largest to smallest.
By Position | The function sorts detected defects by their Caliper index.
By Width | The function sorts detected defects by their width, from the largest to smallest.
Caliper Index | Specifies the Caliper displayed on the image (the Caliper is outlined in green). The default Caliper displayed is 0.
Show | Specifies the display mode for InspectEdgeWidth graphical overlays on top of the image.
0 = hide all (default) | All graphics are hidden, except when the cell containing the InspectEdgeWidth function is highlighted in the spreadsheet.
1 = result graphics only | The line fit, detected defects, outlier points, and gaps are displayed at all times.
2 = result graphics and found edge | The line fit, detected defects, outlier points, gaps, and detected edge points are displayed at all times.
3 = result graphics and caliper detail | The line fit, detected defects, outlier points, gaps, detected edge points, and the indexed Caliper window are displayed at all times.
4 = show all: input and result graphics | Both the input region, line fit, detected defects, outlier points, gaps, and detected edge points are displayed at all times.

Outputs

Returns | An Inspect data structure containing the detected defects, extremes and gaps, or #ERR if any of the input parameters are invalid.
Results | When InspectEdgeWidth is initially inserted into a cell, a results table is created in the spreadsheet. Note: If the value of the Max Number of Defects/Gaps parameter is greater than zero, InspectEdgeWidth will automatically insert a result table containing a maximum of 10 entries that correspond to the first 10 defects/gaps/edges/edge pairs in the 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.

Vision Data Access functions

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

Label | Function | Description
Total Count | GetTotalCount(Inspect) | Returns the total number of results.
Defects/Gaps/Position | GetWidthCount(Inspect, Defects/Gaps/Position) | Returns the total number of specified defects or gaps (Defects = 0, Gaps = 1, Position = 2).
Defects/Gaps/Position
Size/Area/Width/Position | GetDefectGapValue(Inspect, Defect/Gap Index, Defect/Gap/Position, Edge Pair Index, Size/Area/Width) | Returns the size, area or width of the defect or gap (Defect = 0, Gap = 1, Position = 2; Size = 0, Area = 1, Width = 2).
X | GetDefectGapBoundsX(Inspect, Defect/Gap Index, Defect/Gap/Position, Edge Pair Index) | Returns the x-coordinate of the defect's bounding rectangle.
Y | GetDefectGapBoundsY(Inspect, Defect/Gap Index, Defect/Gap/Position, Edge Pair Index) | Returns the y-coordinate of the defect's bounding rectangle.
Height | GetDefectGapBoundsHeight(Inspect, Defect/Gap Index, Defect/Gap/Position, Edge Pair Index) | Returns the height of the defect's bounding rectangle.
Width | GetDefectGapBoundsWidth(Inspect, Defect/Gap Index, Defect/Gap/Position, Edge Pair Index) | Returns the width of the defect's bounding rectangle.
Angle | GetDefectGapBoundsAngle(Inspect, Defect/Gap Index, Defect/Gap/Position, Edge Pair Index) | Returns the angle of the defect's bounding rectangle.
Curve | GetDefectGapBoundsCurve(Inspect, Defect/Gap Index, Defect/Gap/Position, Edge Pair Index) | Returns the curve of the defect's bounding rectangle.
Start/End | GetDefectGapCaliperIndex(Inspect, Defect/Gap Index, Defect/Gap/Position, Edge Pair Index, Defect Start/End) | Returns the Caliper in which the defect starts or ends (Start = 0, End = 1).
Extremes - Furthest Point 1/2
Caliper | GetExtremeWidth(Inspect, Thinnest/Thickest) | Returns the index of the Caliper which contains the specified extreme width (Thinnest = 0 and Thickest = 1).
Width | GetWidth(Inspect, Caliper Index) | Returns the width value of the edge within the indexed Caliper; returns 0 if no edges are found within the indexed Caliper.
X (Start and End) | GetEdgeX(Inspect, Caliper Index, Edge Pair Index or Edge Index) | Returns the x-coordinate of the referenced edge.
Y (Start and End) | GetEdgeY(Inspect, Caliper Index, Edge Pair Index or Edge Index) | Returns the y-coordinate of the referenced edge.

Note:

- All of the formulas for the InspectEdgeWidth conform to the following:

> - Inspect = An Inspect data structure output by an InspectEdgeWidth function
> - Caliper Index = 0 to N (the total number of Calipers is equal to the number of Calipers output by the InspectEdge function that the InspectEdgeForDefect function is referencing)
> - Edge Pair Index = 0 or 1
> - Edge Index = 0 to N
> - Point Index = 0 to 1

- If the Position Enabled parameter is ON, an additional section of InspectEdge Vision Data Access functions will be inserted into the Spreadsheet that relate to Position errors.