Functions > Image Processing > Morphological Processing > Opening and Closing
  
Opening and Closing
The following functions perform binary morphological opening and closing. open performs an erosion followed by a dilation while close performs dilation followed by erosion using threshold b in a pixel neighborhood defined by Melem. These operations are very similar to band-pass filtering and useful for cleaning up the result of thresholding operations.
open(M, Melem, b)—Performs binary opening on matrix M at threshold b using structuring element Melem.
close(M, Melem, b)—Performs binary closing on matrix M at threshold b using structuring element Melem.
Arguments
M is an image matrix.
Melem is a vector or matrix that defines the neighborhood for opening or closing.
b is a real number representing the intensity threshold at which to open or close.
Additional Information
open and close have binary output: foreground is always set to 255, while background is always set to 0. Pixels in the input image M whose grayscale values are below the threshold b are considered background pixels and pixels above b are foreground.
Use open to eliminate foreground features smaller than the structuring element. Opening smoothes contours, suppresses small features in the image, and removes sharp protrusions of shapes. It is ideal for studying the size distribution of objects in images.
Use close to eliminate background features smaller than the structuring element. Closing blocks up narrow channels in shapes and is ideal for studying interobject distances.
Both functions return an image matrix which contains the opened or closed image. As with the erode and dilate functions, pixels near the image boundary may be invalid.
Morphological opening or closing is performed using a structuring element Melem to define the pixel neighborhood. Pixels in the input image M whose grayscale values are below threshold b are considered background pixels, while those above b are considered foreground.
The output image is always binary, with 0 for background and 1 for foreground.
Opening causes foreground features smaller than the structuring element to be eliminated, and closing causes background features smaller than the structuring element to be eliminated. It also smoothes contours, suppresses small features in the image, and removes sharp protrusions of shapes. It is ideal for studying the size distribution of objects in images.
Closing blocks up narrow channels in shapes and is ideal for studying interobject distances.