This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

bwhitmiss

Binary hit-miss operation

Syntax

BW2 = bwhitmiss(BW,SE1,SE2)
BW2 = bwhitmiss(BW,interval)

Description

BW2 = bwhitmiss(BW,SE1,SE2) performs the hit-miss operation defined by the structuring elements SE1 and SE2. The hit-miss operation preserves pixels in binary image BW whose neighborhoods match the shape of SE1 and don't match the shape of SE2.

This syntax is equivalent to imerode(BW,SE1) & imerode(~BW,SE2).

example

BW2 = bwhitmiss(BW,interval) performs the hit-miss operation defined in terms of a single array, called an interval. An interval is an array whose elements are 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.

This syntax is equivalent to bwhitmiss(BW,interval==1,interval==-1).

Examples

collapse all

Create sample binary image for this example.

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]
bw = 6×6

     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

Define an interval.

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

Perform hit-miss operation.

bw2 = bwhitmiss(bw,interval)
bw2 = 6x6 logical array

   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

Input Arguments

collapse all

Binary image, specified as a numeric or logical array of any dimension. For numeric input, any nonzero pixels are considered to be 1 (true).

Flat structuring element, specified as a strel object or a numeric matrix with values of 1 and 0. The neighborhoods of SE1 and SE2 should not have overlapping elements.

Interval, specified as a numeric array with values of 1, 0, and -1.

Data Types: single | double | int8 | int16 | int32 | int64

Output Arguments

collapse all

Processed binary image after the hit-miss operation, specified as a logical array of the same size as BW.

Data Types: logical

See Also

| |

Introduced before R2006a