Lulumoy Studio

Math guide

Morphology

Mathematical morphology operations with a structuring element K (the kernel shape). On binary images, erosion thins shapes and dilation thickens them.

(I⊖K)(x)=mins∈KI(x+s),(I⊕K)(x)=maxs∈KI(x+s)
Erosion (local minimum) and dilation (local maximum).
I∘K=(I⊖K)⊕K,I•K=(I⊕K)⊖K,grad(I)=(I⊕K)−(I⊖K)
Opening (removes protrusions and specks smaller than K), closing (fills holes and gaps smaller than K) and morphological gradient (outline of the shapes).

Parameters

ParameterMeaning
OperationOne of the five operations above.
Kernel shapeShape of K: rectangle, inscribed ellipse or cross.
Kernel sizeSide of K in pixels.
Iterationsn: erosion or dilation is repeated n times (for opening, n erosions then n dilations).

References

  1. OpenCV 4.x documentation — Image Filtering (GaussianBlur, blur, medianBlur, bilateralFilter, morphologyEx). docs.opencv.org/4.x/d4/d86/group__imgproc__filter.html
  2. J. Serra. Image Analysis and Mathematical Morphology. Academic Press, 1982.
  3. R. C. Gonzalez, R. E. Woods. Digital Image Processing, 4th ed. Pearson, 2018.