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.

Morphological Operations

Dilate, erode, reconstruct, and perform other morphological operations


bwhitmissBinary hit-miss operation
bwmorphMorphological operations on binary images
bwmorph3Morphological operations on binary volume
bwskelReduce all objects to lines in 2-D binary image or 3-D binary volume
bwulterodeUltimate erosion
bwareaopenRemove small objects from binary image
imbothatBottom-hat filtering
imclearborderSuppress light structures connected to image border
imcloseMorphologically close image
imdilateDilate image
imerodeErode image
imextendedmaxExtended-maxima transform
imextendedminExtended-minima transform
imfillFill image regions and holes
imhmaxH-maxima transform
imhminH-minima transform
imimposeminImpose minima
imopenMorphologically open image
imreconstructMorphological reconstruction
imregionalmaxRegional maxima
imregionalminRegional minima
imtophatTop-hat filtering
watershedWatershed transform
conndefCreate connectivity array
iptcheckconnCheck validity of connectivity argument
applylutNeighborhood operations on binary images using lookup tables
bwlookup Nonlinear filtering using lookup tables
makelutCreate lookup table for use with bwlookup


strelMorphological structuring element
offsetstrelMorphological offset structuring element

Examples and How To

Dilate an Image to Enlarge a Shape

Dilation adds pixels to boundary of an object. Dilation makes objects more visible and fills in small holes in the object.

Erode an Image To Remove Thin Lines

Erosion removes pixels from the boundary of an object. Erosion removes islands and small objects so that only substantive objects remain.

Operations That Combine Dilation and Erosion

Combine dilation and erosion to remove small objects from an image and smooth the border of large objects.


Morphological Dilation and Erosion

Dilation adds pixels to the boundary of objects in an image. Erosion removes pixels from object boundaries.

Structuring Elements

A structuring element defines the neighborhood used to process each pixel. It influences the size and shape of objects you want to process in the image.

Understanding Morphological Reconstruction

Morphological reconstruction is useful to extract marked objects from an image without changing the object size or shape.


The process of skeletonization reduces all objects in an image to lines, without changing the essential structure of the image.

Find Object Perimeters

The perimeter, or boundary, of objects in a binary image consists of all pixels at the interface of the object and the background.

Correct Nonuniform Background Illumination and Analyze Foreground Objects

This example shows how to enhance an image as a preprocessing step before analysis.

Lookup Table Operations

A lookup table is a vector in which each element represents the different permutations of pixels in a neighborhood. Lookup tables are useful for custom erosion and dilation operations.

Was this topic helpful?