# Edge

In machine vision terminology, an edge is defined as the boundary (either a line, arc or circle) between two adjacent pixel groups with contrasting greyscale values. The In-Sight Edge Tools are used to detect and process statistics about the found edges.

## What is Edge Detection?

The In-Sight Edge Tool functions detect edges by examining a region of interest (ROI) for discontinuities in pixel polarity, such as an area in the image where there is an abrupt change between light and dark (or vice versa) pixels. An edge might only span two or three pixels, or several.

## Edge Example

Edges can be comprised of a single edge, or a pair of edges, which consists of two transitions from dark to light or light to dark. The figure shows the types of edges:

When an Edge Tool, such as a Caliper, FindLine or FindCircle function, is inserted into the spreadsheet, the ROI is scanned for any pixel value discontinuities. The figure illustrates the direction in which rectangular and annular regions are scanned for edge features. In the rectangular region, the scan direction (the scan direction is indicated by the two directional arrows) starts from the upper-most left-hand corner, and proceeds to the end of the right-hand side, and then continues the pattern until it reaches the bottom right-hand corner.

## Scan Directions - Rectangular and Annular Regions

During this process, a greyscale histogram is computed of the ROI, and areas defined by high contrast (the difference between greyscale values found within the ROI) and meeting the other specified parameters, define an edge.

The edge response chart (displayed when the Show parameter is set to show all: input, result, and chart) displays the first derivative of the greyscale values found in the ROI; with peaks and valleys representing the major edge transitions, as shown in the figure below. The Accept Thresh/Minimum Contrast parameter is used to set a minimum peak height (contrast threshold). With this set, any peaks that are lower than the minimum peak height are excluded from the results. This allows the inspection analysis to be limited to just those edges in the image that are of a certain magnitude. Use the edge response chart of the function to determine the correct contrast threshold.

## Edge Response Chart Example

- The Score axis is defined by the Score (100 and -100) and the Accept Threshold parameter set for the tool. Peaks (or positive scores) indicate that the edge transitions from dark to light, while valleys (or negative scores) indicate that the edge transitions from light to dark (a score of 0 indicates no edge was detected).
- The Offset axis refers to the ROI of detecting the edge feature, where 0 represents the beginning of the region and the right-hand value marks the maximum width (in pixels) of the region. The apex of the peaks or valleys along the Offset axis indicates the position of the found edge within the ROI.

## Edge Width - Filtering Edges

The Edge Width parameter is used to remove noise from the input image, and accentuate the peaks of the edge profiles. The size of the Edge Width parameter should be specified such that the size closely matches the size of the edges in the image, and the peak is sharp and steep, versus low and gradual. The size of an edge is how many pixels wide the edge is. An edge can be sharp, in which case the edge only spans a pixel or two, or edges can be dull, in which case they might span several pixels. Specifying an Edge Width setting that is close to the edge size allows the function to produce stronger edge peaks in the image. Whereas specifying an Edge Width setting that is too large or too small will produce broad, low peaks in the image.

## Edge Results

Once the edge has been defined, the Edge Tool function will automatically create an Edges data structure and a result table that contains data about the defined edge. The information returned can be utilized by other In-Sight 2D Vision Tools as a fixture input, or used by other Edge Tool functions to further extrapolate edge related data.

## When are Edge Tools Used?

The Edge Tools should be used in the following circumstances:

- The edge has a high contrast between light and dark pixels.
- The application requires quick detection of features. The Edge Tools are among the fastest In-Sight Vision Tools, providing the ability to detect edge features faster than patterns, for example.

Note: The In-Sight Edge Tools only analyze greyscale images. All color images are automatically converted to a greyscale value.

## Why are Edge Tools Used?

Edge detection and data extrapolation can be extremely useful in applications such as the following:

- Gauging applications, such as measuring the radius of circular features on parts such as gaskets, or measuring the length of circuits on a circuit board.
- Locating features on parts, such as circular features or the straight ends of parts, to use as fixture inputs for other In-Sight Vision Tools.
- Presence/absence applications, where the Edge Tools are used to determine whether or not an edge feature is present or absent.
- Counting and sorting applications, where the Edge Tools are used to count and sort edges based on their established parameters.

Note: When using a horizontal or vertical linear edge feature as a fixture input, the FindLine tool will only account for the movement of the edge in one direction, either along the horizontal or vertical axis, depending on the position of the scan direction of the ROI.

## How to Use the Edge Tools

The Edge Tools are typically utilized in the following order:

1. The image is examined and a determination is made that an edge tool meets the requirements of the application.
2. One of the Edge Tools, such as Caliper, FindCircle, FindCircleMinMax, FindCurve, FindLine, FindMultiLine or FindSegment, is inserted into the spreadsheet and the parameters are configured to define and detect the edge or edge pairs in the image.
3. Another of the Edge Tools, such as a PairDistance, PairEdges, PairMaxDistance, PairMeanDistance, PairMinDistance, PairSDevDistance, PairsToEdges or SortEdges, is inserted to filter, compute or sort the found edges or edge pairs, based on specific criteria.