Functions > Image Processing > Morphological Processing > Grayscale Morphology
  
Grayscale Morphology
gray_close(M, Melem)—Performs grayscale closing on matrix M with structuring element Melem.
gray_dilate(M, Melem, r_origin, c_origin)—Performs grayscale dilation on matrix M using structuring element Melem with origin at row r_origin and column c_origin.
gray_erode(M, Melem, r_origin, c_origin)—Performs grayscale erosion on matrix M using structuring element Melem with origin at row r_origin and column c_origin.
gray_open(M, Melem)—Performs grayscale opening on matrix M with structuring element Melem.
Each function returns a matrix containing the result of the morphological operation.
Arguments
M is an image matrix.
Melem is a structuring vector or matrix.
r_origin, c_origin are integers, where sign indicates direction, representing the row and column origin of Melem.
Details of gray_erode Function
In binary erosion, a structuring element is used to define a neighborhood around each pixel in which the presence of any background pixels cause the foreground to become background. Grayscale erosion is an extension of this, where the structuring element's pixel values are subtracted from the input image's pixel values. The output is the minimum resulting pixel value within the boundary of the structuring element.
The effects of grayscale erosion, if the structuring element has all positive values, are:
to reduce the overall brightness of the image
to eliminate bright regions in the image that are smaller than the structuring element
to expand dark regions of the image
If the grayscale image and structuring element are thought of as surfaces whose heights at each point are their grayscale values, grayscale erosion causes the height of the input surface to be reduced by the height of the structuring element, and small, tall features to be completely eroded away.
Image boundaries are treated as though they extend outwards with zero grayscale values, so output pixels nearer to the edges of the image than the size of the structuring element may be invalid.
Details of gray_dilate Function
In binary dilation, a structuring element is used to define a neighborhood around each pixel in which the presence of any foreground pixel causes the background to become foreground. Grayscale dilation is an extension of this, where each pixel in the output is produced by rotating the structuring element by 180 degrees, and centering it on a pixel, and adding its pixel values to the input image. The output pixel value is the maximum resulting pixel value within the boundary of the structuring element.
The effects of grayscale dilation, if the structuring element has all positive values, are:
to increase the overall brightness of the image
to eliminate dark regions in the image that are smaller than the structuring element
to expand bright regions of the image
If the grayscale image and structuring element are thought of as surfaces whose heights at each point are their grayscale values, grayscale dilation causes the height of the input surface to be increased by the height of the structuring element and small, deep valleys to be completely filled in.
The image boundaries are treated as though they extended outwards with zero grayscale values, so output pixels nearer to the edges of the image than the size of the structuring element may be invalid.
Details of gray_open and gray_close Functions
Grayscale opening and closing are defined in an analogous way to opening and closing in binary morphology; opening is grayscale erosion followed by grayscale dilation, and closing is grayscale dilation followed by grayscale erosion. Note that because of the 180-degree rotation of the structuring element in dilation, both open and close operations are invariant to the origin of the structuring element.
The main effect of grayscale opening is to remove small, bright features from the image, while leaving the overall brightness unchanged.
The main effect of grayscale closing is to remove small, dark features from the image, while leaving the overall brightness unchanged.
Image boundaries are handled as if the image extended outward with zero grayscale value, so the output pixels nearer to the edges of the image than the size of the structuring element may be invalid.