Image Processing Toolbox | ![]() ![]() |
Syntax
Description
BW2 = bwhitmiss(BW1,SE1,SE2)
performs the hit-and-miss operation defined by the structuring elements SE1
and SE2
. The hit-and-miss operation preserves pixels whose neighborhoods match the shape of SE1
and don't match the shape of SE2
. SE1
and SE2
may 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-and-miss operation defined in terms of a single array, called an interval. An interval is an array whose elements can contain either 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(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 with the same size as BW1
. SE1
and SE2
must be flat STREL
objects or they must be logical or numeric arrays containing 1s and 0s. INTERVAL
must be an array containing 1
s, 0
s, and -1
s.
Example
This example performs the hit-and-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
![]() | bwfill | bwlabel | ![]() |