Main Content

Morphological Operations

Dilate, erode, reconstruct, and perform other morphological operations

Morphology is a broad set of image processing operations that process images based on shapes. In a morphological operation, each pixel in the image is adjusted based on the value of other pixels in its neighborhood. By choosing the size and shape of the neighborhood, you can construct a morphological operation that is sensitive to specific shapes in the input image.


expand all

imerodeErode image
imdilateDilate image
imopenMorphologically open image
imcloseMorphologically close image
imtophatTop-hat filtering
imbothatBottom-hat filtering
imclearborderSuppress light structures connected to image border
imkeepborderRetain light structures connected to image border (Since R2023b)
imfillFill image regions and holes
bwhitmissBinary hit-miss operation
bwmorphMorphological operations on binary images
bwmorph3Morphological operations on binary volume
bwperimFind perimeter of objects in binary image
bwskelReduce all objects to lines in 2-D binary image or 3-D binary volume
bwulterodeUltimate erosion
imreconstructMorphological reconstruction
imregionalmaxRegional maxima
imregionalminRegional minima
imextendedmaxExtended-maxima transform
imextendedminExtended-minima transform
imhmaxSuppress regional maxima in image using H-maxima transform
imhminSuppress regional minima in image using H-minima transform
imimposeminImpose minima
strelMorphological structuring element
offsetstrelMorphological offset structuring element
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
bwpackPack binary image
bwunpackUnpack binary image


Elements of Morphology

  • Types of Morphological Operations
    The most basic morphological operations are dilation and erosion. You can combine dilation and erosion for more specialized operations.
  • Morphological Reconstruction
    Morphological reconstruction is used to extract marked objects from an image without changing the object size or shape.
  • Structuring Elements
    A structuring element defines the neighborhood used to process each pixel. A structuring element influences the size and shape of objects to process in the image.
  • Border Padding for Morphology
    Morphological dilation and erosion pad the image border in different ways to avoid border effects.
  • Pixel Connectivity
    Connectivity determines whether a center pixel and adjacent pixels belong to the same object.
  • 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.

Applications of Morphology