bwhitmiss

Binary hit-miss operation

Syntax

BW2 = bwhitmiss(BW1,SE1,SE2)
BW2 = bwhitmiss(BW1,INTERVAL)

Description

BW2 = bwhitmiss(BW1,SE1,SE2) performs the hit-miss operation defined by the structuring elements SE1 and SE2. The hit-miss operation preserves pixels whose neighborhoods match the shape of SE1 and don't match the shape of SE2. SE1 and SE2 can be flat structuring element objects, created by strel, or neighborhood arrays. The neighborhoods of SE1 and SE2 should not have any overlapping elements. The syntax bwhitmiss(BW1,SE1,SE2) is equivalent to imerode(BW1,SE1) & imerode(~BW1,SE2).

BW2 = bwhitmiss(BW1,INTERVAL) performs the hit-miss operation defined in terms of a single array, called an interval. An interval is an array whose elements can contain 1, 0, or -1. The 1-valued elements make up the domain of SE1, the -1-valued elements make up the domain of SE2, and the 0-valued elements are ignored. The syntax bwhitmiss(BW1,INTERVAL) is equivalent to bwhitmiss(BW1,INTERVAL == 1, INTERVAL == -1).

Class Support

BW1 can be a logical or numeric array of any dimension, and it must be nonsparse. BW2 is always a logical array the same size as BW1. SE1 and SE2 must be flat STREL objects or they must be logical or numeric arrays containing 1's and 0's. INTERVAL must be an array containing 1's, 0's, and -1's.

Examples

Perform the hit-miss operation on a binary image using an interval.

bw = [0 0 0 0 0 0
      0 0 1 1 0 0
      0 1 1 1 1 0
      0 1 1 1 1 0
      0 0 1 1 0 0
      0 0 1 0 0 0]

interval = [0 -1 -1
            1  1 -1
            0  1  0];

bw2 = bwhitmiss(bw,interval)

bw2 =

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

See Also

| |

Was this topic helpful?