# Caliper

Measures gap widths using a gray-level profile.

If image is connected, computes a gray-level profile of the given rectangular region and finds edges of the gaps in the profile.

If profile is connected, finds edges of the gaps in a precalculated profile.

## Inputs

image
Input image. If connected, profile must not be connected.
profile
1-by-N gray-scale profile vector originating e.g. from ProfileTool. If connected, image must not be connected and width will be ignored.
startPoint
The location of the first profile point in world coordinates.
endPoint
The location of the last profile point in world coordinates.
width
The width of the profile line on XY-plane in world coordinates. If the width is zero, the profile will be made of point samples. A non-zero width means that an average over the pixels that span width world units will be calculated. Has effect only if image is connected and profile and length are not connected.
interpolation
If true, improve accuracy by interpolating point samples between pixels along the profile line. If false, round pixel coordinates to the nearest integer. Notice that interpolation is a significantly slower operation than rounding.
algorithm
Gap edge detection algorithm. Gap edges are detected from filtered profile using the selected algorithm.
smoothness
Smoothness of the profile filter. Small smoothness value works best with sharp edges. Large smoothness value gives better results if the edges are dull or the image is noisy.
threshold
The following condition must be met at be met before a filtered profile entry is considered to be a start / end of a gap: Absolute mode: Filtered gray level must be larger than this. Differential mode: Rate of change must be larger than this. Gaussian zero crossing mode: Two consecutive 2nd order differences must be of opposite signs and their difference must be larger than this.
hysteresis
Hysteresis to the threshold Absolute mode: The threshold must be exceeded by this number before the pixel is considered an edge. Differential mode: Pixel at which the rate of change is local maximum minus hysteresis is set as an edge. Gaussian zero crossing mode: N/A
maxGapCount
maximum number of gaps to be detected
gapType
Gap type selector. Report only gaps of the selected type. DarkOrLightGap reports both gap types.

## Outputs

filteredProfile
Filtered vector which is matched against the threshold. In absolute mode contains smoothed input profile. In differential mode contains filtered differences. In zero crossing mode contains filtered 2nd order differences.
gapStartLength
distance of the left edge of the gap from the beginning of the profile line in world coodinates.
gapEndLength
distance of the right edge of the gap from the beginning of the profile line in world coodinates.
gapWidth
Width of the gap in world coordinates
gapType
Type of the gap. 0 = dark gap, 1 = light gap.
gapMagnitude
Magnitude of the filtered profile which exceeded the threshold for the left edge of this gap. The bigger the value, the sharper the edge is. Absolute mode: Maximum gray level in light gap and minimum gray level in dark gap. Differential mode: Maximum change in light gap (>0) and minimum change in dark gap (<0) at the left edge of the gap. Gaussian zero crossing mode: Difference between the two consecutive 2nd order differences with opposite signs.
gapStartPoint
World coordinates of the left end of the gap on XY-plane
gapCenterPoint
World coordinates of the center of the gap on XY-plane
gapEndPoint
World coordinates of the right end of the gap on XY-plane

Supported algorithms

Enumerator
AbsoluteThreshold

Detect gap boundaries at positions where the given threshold gray level is crossed in either direction.

DifferentialThreshold

Detect gap boundaries at steepest gray level changes. Positive changes mean a dark-to-light boundary and negative changes a light-to-dark boundary.

GaussianZeroCross

Marr-Hildreth edge detector. First filters the input profile with a Gaussian filter whose width is changed according to the smoothness parameter. A second order differential function is then computed. Zero crossings of this differential function indicate the points at which the change of magnitude is the largest. These points are selected as boundaries.

 enum CaliperTool::GapType

Gap filter types

Enumerator
DarkGap

Report only dark gaps.

LightGap

Report only light gaps.

DarkOrLightGap

Report both gap types.