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.2 Set Description of Binary Images
The language of mathematical morphology is that of set theory. Sets in mathematical morphology represent the shapes that are visible in binary images. The set of all the white (or black) pixels in a binary image constitutes a complete description of the image. Each element of the set is a 2-tuple of integer values identifying the Cartesian coordinates of each white (or black) pixel with respect to some assumed coordinate center. It is typical to assume that the coordinate center coincides with a corner element of the array.
ToSet
[
img
]
returns
ToSet
[
img
,
cntr
]
returns
ToSet
[
img
,
cntr
,
v
]
returns
FromSet
[
dims
,
set
]
creates an array of dimensions
dims
with ones in positions given by
set
FromSet
[
dims
,
set
,
cntr
]
returns an array of dimensions
dims
with ones in positions given by
set
relative to
cntr
FromSet
[
dims
,
set
,
cntr
,
{
a
,
b
}
]
returns
,
with element
a
in positions given by
set
relative to
cntr
,
and b otherwise
GlobalSet
[
{
n
,
m
}
,
cntr
]
returns a list of all positions in an array of dimensions
n × m
and a center at
cntr
ComplementSet
[
,
]
returns all the elements of set
that are not in set
Set-theoretic functions.
This loads the package.
In[1]:=
Here is an example binary image.
In[2]:=
The set description
of image A is obtained by locating all the ones in the image. We assume the default origin location at position {1, 1} in array
A
and return all positions as offsets from the origin. Different choices for the location of the origin result in different set descriptions
. The set descriptions differ by a translation.
In[3]:=
Out[3]=
To obtain the set complement (or background image) of some set
, it is necessary to define the global set
, a set of all coordinate pairs of an N
1
× N
2
image.
In[4]:=
Out[4]=
Here is the set complement.
In[5]:=
Out[5]=
Here we view the complement image.
In[6]:=
Out[6]//MatrixForm=
The set description of a translation of a set is the vector sum of the positions of the elements of the set with a translation vector. Consider a translation of set
by the vector {1,1}.
In[7]:=
Out[7]=
In[8]:=
Out[8]//MatrixForm=
The set description of a reflection of a set
with respect to element
0
is the vector difference of
0
and the position of each element of the set. Typically,
0
is the origin. However, in the context of a matrix implementation of reflection, it is more convenient to set
0
={N
1
-1,N
2
-1}, where N
1
, N
2
are the row and column dimensions of the matrix.
In[9]:=
Out[9]=
In[10]:=
Out[10]//MatrixForm=
In matrix notation, reflection of an N
1
× N
2
array A denoted
, is defined
where
is the
r
th and
c
th element of array
. The last result is the same as that obtained using the function
Reflect
.
In[11]:=
Out[11]=
The set theoretic concepts of translation and reflection will be used in the next section to define the fundamental operators of binary morphology