Function File: bwhitmiss (bw, se1, se2)
Function File: bwhitmiss (bw, interval)

Perform binary hit-or-miss transform.

This transform returns the set of positions, where the structuring element se1 fits in the foregrond of bw, while the structuring element se2 misses it completely. It is equivalent to:

imerode (bw, se1) & imerode (! bw, se2)

For example, the following will remove every pixel with adjacent horizontal foreground pixels:

>> bw = [ 0   1   0   1   1   0
          0   1   0   1   1   0
          0   1   0   1   1   0];

>> bwhitmiss (bw, [1; 0; 1], [1 0 1])
  ⇒ ans =

          0   1   0   0   0   0
          0   1   0   0   0   0
          0   1   0   0   0   0

Note that while se1 and se2 must have disjoint neighbourhoods for this transform to be meaningful, no error or warning is throw about it.

Alternatively a single array interval can be defined, of values from [1 0 -1]. In this case, the two structuring elements are extracted as:

se1 = (interval ==  1)
se2 = (interval == -1)

See also: bwmorph.

Package: image