image thumbnail

Binary Morphology in Image Processing

version 1.2.0 (1.33 MB) by Emma Smith Zbarsky
Interactive courseware module that introduces the fundamental morphological operations used in image processing.


Updated 06 Oct 2021

From GitHub

View license on GitHub

Binary Morphology in Image Processing View Binary Morphology in Image Processing on File Exchange

Curriculum Module
Created with R2020a. Compatible with R2020a and later releases.


This package contains a live script and supporting files to illustrate and apply the fundamentals of morphological operations used for processing binary images. The materials are designed to be flexible and can be easily modified to accommodate a variety of teaching and learning methods. The package includes definitions and a brief background, interactive illustrations of concepts, guided tasks, reflection questions, application examples, and practice problems for the concepts explored in this module.

Learning Goals

  • Define and apply the primary morphological operations—erosion and dilation.
  • Explain the use of relational and logical operators in the context of binary image processing.
  • Define and apply compound morphological operations like opening and closing.
  • Explain the effect of using structuring elements of different shapes and sizes for each morphological operation.
  • Identify and apply the appropriate morphological operations and structuring elements to achieve a given processing outcome.
  • Use simple shapes to filter objects in an image.

This module contains several illustrative animations. For the best experience, run it one section at a time to begin. The instructions will guide you through each section while also allowing for free exploration of ideas. To stop running the script or a section midway (for example, when an animation is in progress), use the Stop button in the Run section of the Live Editor tab in the MATLAB® toolstrip.

Suggested Prework

MATLAB Onramp – a free two-hour introductory tutorial to learn the essentials of MATLAB.


This is an interactive guided lesson that introduces the fundamentals of morphological image processing. Students identify and apply basic operators to process binary images to perform tasks such as extracting object boundaries and filtering objects by shapes. It is the main script for this module.

This is a supplementary script containing solutions to the three guided practice problems contained in binaryMorphologyBasics.mlx.

This folder contains several binary images used for illustration and practice in binaryMorphologyBasics.mlx. The main script adds this folder to your search path and provides controls to switch between the images when applicable. Ensure that this folder is in the same folder as the main script. Alternatively, ensure that all the required images are in the MATLAB search path.


MATLAB, Image Processing Toolbox™


The license for this module is available in the LICENSE.TXT file in this GitHub repository.

Educator Resources

Have any questions or feedback? Contact the MathWorks online teaching team.

Copyright 2021 The MathWorks, Inc.

Cite As

Emma Smith Zbarsky (2021). Binary Morphology in Image Processing (, GitHub. Retrieved .

MATLAB Release Compatibility
Created with R2020a
Compatible with R2020a and later releases
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
To view or report issues in this GitHub add-on, visit the GitHub Repository.
To view or report issues in this GitHub add-on, visit the GitHub Repository.