Binary Morphology

Binary Morphology

Applies morphological operations to binary images. Typically used for noise reduction and shape enhancement in thresholded images.

Inputs

image
A binary image. All non-zero pixels in the input image are regarded as foreground.
operation
The morphological operation to apply to the input.
maskSize
The size of the morphological mask (a.k.a the structuring element) in world coordinates. If the mask is bigger than the input image, the output image will be filled with zeros.
maskShape
The shape of the structuring element.
expandBorders
A flag that indicates whether foreground objects on image borders are assumed to expand beyond the edge. Setting this property to true makes the algorithm slower.

Outputs

image
A binary image.
Enumerator
RectangularMask 

The whole mask is filled with ones. Large masks produce jagged output.

EllipticalMask 

Circle or ellipse, depending on the size of the mask. Produces smooth, round output.

DiamondMask 

A diamond. A compromise between the others.

Enumerator
Erode 

Erosion. Shrinks blobs and completely removes small ones.

Dilate 

Dilation. Enlarges blobs.

Open 

Erosion followed by dilation. Removes small blobs and juts, and breaks thin connections between blobs.

Close 

Dilation followed by erosion. Closes holes in blobs and gaps between blobs.

TopHat 

Original minus opened. Leaves only the small elements removed by opening. Also known as the white top-hat transformation.

BottomHat 

Closed minus original. Leaves the small elements added by closing. Also known as the black top-hat transformation.