Operator HitOrMiss

The operator HitOrMiss performs a morphological hit-or-miss operation of the binary image, which can be used to identify structures or objects. The input is a kernel-stream (see e.g. FIRkernelNxM). The output link gives the calculated value for the center pixel. A structuring element for the hit-or-miss operation is given by a parameterizable matrix. The matrix has the size of the input kernel.

The output is set to '1' for a pixel if the kernel neighborhood of the pixel exactly matches with the pattern defined in the parameter StructElement. The output is set to '0' if there are one or more mismatches. The search pattern defined with parameter StructElement can be either 0 or 1 to define the match. Moreover, value -1 is allowed, too. It defines a don't care value for ignored parts in the structuring element.

Let's have a look at an example. The following struct element is given.

We will match it with the following image I

If we match the structuring element with the image the output O is

To generate the required input kernel use operators such as FIRkernelNxM, LineNeighboursNx1 or PixelNeighbours1xM.

I/O Properties

Property Value
Operator Type O
Input Link I, kernel input
Output Link O, data output

Supported Link Format

Link Parameter Input Link I Output Link O
Bit Width 1 as I
Arithmetic unsigned as I
Parallelism any as I
Kernel Columns any 1
Kernel Rows any 1
Img Protocol {VALT_IMAGE2D, VALT_LINE1D, VALT_PIXEL0D} as I
Color Format VAF_GRAY as I
Color Flavor FL_NONE as I
Max. Img Width any as I
Max. Img Height any as I

Parameters

StructElement
Type static parameter
Default -1
Range {-1, 0, 1}

This parameter defines the shape of the structuring element.

  • A '0' in the struct element has to match with a '0' in the respective kernel input.

  • A '1' in the struct element has to match with a '1' in the respective kernel input.

  • A '-1' in the struct element marks the position as don't care and will be ignored.

If the input kernel size of the operator is changed, the coefficients will also change. Check the coefficients after changing the input kernel size.

Examples of Use

The use of operator HitOrMiss is shown in the following examples:

  • 'Hit or Miss'

    Examples - The implementation can detect four simple patterns in a binary image. For every match, the output will be set to one.