WOLFRAM
Products
Wolfram|One
Mathematica
Wolfram Notebook Assistant + LLM Kit
Wolfram|Alpha Notebook Edition
System Modeler
All Products
Consulting & Solutions
Wolfram Consulting
Industry Solutions
Solutions for Education
Learning & Support
Wolfram U Courses
Wolfram Language Resources
Wolfram Community
Support FAQs
Contact Support
Company
About Wolfram
Careers
Events
Educational Programs
All Sites and Resources
Wolfram|Alpha
Wolfram Cloud
Your Account
Your Account
User Portal
Search
Close
Enable JavaScript to interact with content and submit forms on Wolfram websites.
Learn how
Legacy Documentation
Digital Image Processing
(2000)
This is documentation for an obsolete product.
Current products and services
User's Guide
Morphology
6.4 Grayscale Morphological Operators
Morphological concepts may be extended to grayscale images. The common approach is to use a grayscale extremum operation over a small neighborhood defined by the structuring element. Grayscale dilation is a convolution-like operation. A typically small structuring element is scanned over an image and, at each position, the maximum of point-by-point sums of the image and the structuring element is computed. For notational convenience we assume arrays with square dimensions. Then, given a 2M+1×2M+1 structuring element B and an N×N image array A, the dilation of A by B may be defined as
for all i,j such that -M≤i,j≤M, with 0≤n
1
,n
2
≤N-1. For example, with M=1 and B(i,j)=0 for all
i, j
, we get
Dilation tends to grow the white regions of an image. If the structuring element has positive values, the resulting image tends to be brighter.
Grayscale erosion is the dual of grayscale dilation; the structuring element values are subtracted from the image during the scanning process and a minimum of each set of values is returned. This may be implemented as a correlation-like operation where the extremum operator
Min
and subtraction replace multiplication and addition, respectively. Given a 2M+1×2M+1 structuring element B and an N×N image array A, the erosion of A by B may be defined as
for all i,j such that -M≤i,j≤M, with 0≤n
1
,n
2
≤N-1. Erosion tends to shrink the white regions of an image. If the structuring element has positive values, the resulting image tends to be darker.
GrayscaleDilate
[
img
,
s
]
gives
GrayscaleErode
[
img
,
s
]
gives
GrayscaleClose
[
img
,
s
]
gives
GrayscaleOpen
[
img
,
s
]
gives
GrayscaleTopHat
[
img
,
s
]
gives
Grayscale morphology functions.
This loads the package.
In[1]:=
Here we choose a 3×3 structuring element of ones and generate a box-like image.
In[2]:=
Here is the dilation result.
In[3]:=
Out[3]//MatrixForm=
Here is the result of eroding the previous output.
In[4]:=
Out[4]//MatrixForm=
Here is an example of grayscale dilation and erosion of the example
books
image. The structuring element
B
is defined as a uniform array of ones.
In[5]:=
In[6]:=
Out[6]=
Grayscale dilation and erosion are frequently concatenated to form grayscale open and close operators. The expressions for opening and closing have the same form as their binary counterparts. The closing of image A by structuring element B is simply the dilation of A by B, followed by erosion of the result with B (see Equation (6.3.7)). Similarly, the opening of A by B, is an erosion of A followed by dilation (see Equation (6.3.8)).
In[7]:=
Out[7]=
The morphological top-hat transformation (also known as the white top-hat transformation) is defined as
where
is the grayscale open operation. This transformation is useful for enhancing positive peaks in the dark areas of an image. The structuring element should be larger than the peaks.
In[8]:=
Out[8]=