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.


Input image. If connected, profile must not be connected.
1-by-N gray-scale profile vector originating e.g. from ProfileTool. If connected, image must not be connected and width will be ignored.
The location of the first profile point in world coordinates.
The location of the last profile point in world coordinates.
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.
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.
Gap edge detection algorithm. Gap edges are detected from filtered profile using the selected algorithm.
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.
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 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
maximum number of gaps to be detected
Gap type selector. Report only gaps of the selected type. DarkOrLightGap reports both gap types.


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.
distance of the left edge of the gap from the beginning of the profile line in world coodinates.
distance of the right edge of the gap from the beginning of the profile line in world coodinates.
Width of the gap in world coordinates
Type of the gap. 0 = dark gap, 1 = light gap.
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.
World coordinates of the left end of the gap on XY-plane
World coordinates of the center of the gap on XY-plane
World coordinates of the right end of the gap on XY-plane

Supported algorithms


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


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


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.

Gap filter types


Report only dark gaps.


Report only light gaps.


Report both gap types.