Digital image processing
M o r r p h o l l o g i i c a l l i i m a g e a n a l l y s i i s .
.
B i i n a r r y m o r r p h o l l o g y o p e r r a t t i i o n s
I I n t t r o d u c t t i i o n
The morphological transformations extract or modify the structure of the particles in an image. Such transformations can be used to prepare the particles for the quantitative analysis, for the analysis of the geometrical properties or for extracting the simplest modeling shapes and other operations.
The morphological operations can also be used for expanding or reducing the particle dimensions, gap “filling” or closing inclusions, the averaging of the particle edges and others.
The morphological transformations are separated in two main categories:
binary morphological gray functions, which are applied for binary images level morphological functions, which are applied for gray-level images
A binary image is an image which was segmented into an object region (which contains particles – typically the object pixels are coded by ones) and a background region
(typically the background pixels are coded by zeros). The most simple segmentation process is by binary thresholding the gray-level images.
B i i n a r r y m o r p h o l l o g y
The structuring element is a mask used by most of the morphological transformations.
It can be used to determine the effect that these transformations have on a particle in the image.
A morphological transformation that uses a structuring element modifies the P
0 pixel such that its value will be a function whose parameters will be the neighbouring pixels. Only the neighbouring pixels masked with the “1” values of the structuring element are used for transformation, as one can notice in Figure 1.
Figure 1 The structuring element
1
6.
Morphological image analysis. Binary morphology operations
The structuring element is a binary mask composed of 0 and 1 elements. It is used to determine which one of the neighbouring pixels will contribute to computing the new value of the current pixel P
0
. The shape of the structuring element can be rectangular or hexagonal as it can be seen in Figure 2 and Figure 3 respectively.
Figure 2 The rectangular structuring element with a 3x3 dimension
Figure 3 The hexagonal structuring element with a 5x3 dimension
The default configuration of a structuring element is a matrix of 3x3 elements where each element is 1.
B a s i i c m o r r p h o l l o g i i c a l l t t r r a n s f f o r r m a t t i i o n s o f f b i i n a r y i i m a g e s
The basic morphological transformations include two types of processing: erosion and dilation . The other types of transformations are obtained by combining these two operations.
Erosion
The erosion eliminates the isolated pixels from the background and erodes the boundaries of the object region, depending on the shape of the structuring element. For a given pixel P
0 we will consider the structuring element centered in P
0 and we will denote with P i the neighboring pixels that will be taken into consideration (the ones corresponding to the coefficients of the structuring element having the value 1). We can say that:
if a pixel P i
is zero, then P
0 is zero, otherwise P
0
is one
if AND( P i
)=1 then P
0
=1, otherwise P
0
=0
Dilation
The dilation process has the inverse effect of the erosion process, because the particle dilation is equivalent to the background erosion. This process eliminates the small and isolated gaps from the particles and enlarges the contour of the particles depending on the shape of the structuring element. For a given pixel P
0 we will consider the structuring element centered in P
0 and we will denote with P i the neighboring pixels that will be taken
2
Digital image processing into consideration (the ones corresponding to the coefficients of the structuring element having the value 1). We can say that:
if a pixel P i is one, then P
0 is one, otherwise P
0
is zero
if OR( P i
)=1 then P
0
=1, otherwise P
0
=0
Further we will present some examples of these two operations. The image in Figure 4 is the source image, and the gray cells represent the pixels that have value 1 (object pixels).
Figure 4 The source image
Depending on the structuring element, the erosion and the dilation results will be different as it can be observed in Tables 1 and 2 below.
Table 1. The results of the erosion process for two types of structuring elements
Structuring element After erosion Operation description
A pixel is deleted if it has the value 1 and it doesn’t have three top left neighboring pixels of value 1. The erosion process eliminates the top left edges of the particles.
A pixel is deleted if it has the value 1 and if the two neighboring pixels, the one from its right side and the one from the bottom, are not equal with 1. The erosion process eliminates the edges from the right side and from the bottom of the particles, but it keeps their contours.
3
6.
Morphological image analysis. Binary morphology operations
Table 2. The results of the dilation process for two types of structuring elements
Structuring element After dilation Operation description
A pixel has the value 1 if it is one or if any of the three neighboring pixels from the its left side is 1. The dilation increases the top-left edges of the particles.
A pixel has the value 1 if it is equal with 1or if one of the two neighboring pixels, from the right side and from the bottom part, is 1. The dilation increases the right and the bottom edges of the particles.
O t t h e r r t t y p e s o f f b i i n a r r y m o r r p h o l l o g i i c a l l t t r r a n s f f o r r m a t t i i o n s
The opening function – represents the process of erosion followed by dilation. This function eliminates the small particles and makes the particle contours smoother. If we have an image I , then: Opening (I) = dilation (erosion (I))
The closing function - represents the process of dilation followed by erosion. This function has the role to fill the small gaps that appear in the particles and to make the particle contours smoother. If we have an image I , then: Closing (I) = erosion (dilation (I))
The hit-miss function – is used to localize particular pixel configurations. This extracts each pixel from an image, pixel placed between neighbors who respect the configuration of the structuring element. With the help of this function isolated pixels or different shapes of the particles can be detected etc. The larger the dimension of the structuring element is, the more exact is the searching process. In Figure 5 a few examples are presented; the source image is the same as in Figure 4:
4
Digital image processing
Figure 5 Examples of the hit-miss function use
M o r r p h o l l o g i i c a l l t t r r a n s f f o r r m a t t i i o n s o f f g r r e y l l e v e l l i i m a g e s
These functions are applied to images that have more than two levels. These functions are used to modify the shape of the areas by extending the bright areas and reduce the dark areas, and vice-versa. The morphological transformation types encountered in this case are mainly the same as the ones used for the binary images: erosion, dilation, closing, opening etc.
L a b V i i e w I I M A Q F u n c t t i i o n s f f o r M o r r p h o l l o g i i c a l l A n a l l y s i i s
IMAQ Threshold
The function leads to a binary image by thresholding a grey scale image.
Keep/Replace Value(Replace)
– determines if the pixels that have the value in the Lower value and Upper value interval will be replaced or kept.
Image Src – is the reference to the source (input) image.
Image Dst – is the reference to the destination image. If it is connected, it must be the same type as the Image Src.
Image Dst Out – is the reference for the destination image.
Range – is a data structure specifying the threshold domain and it has two values:
Lower value – is the smallest value of the pixel involved in the
thresholding. The default value is 128.
Upper value – is the highest value of the pixel involved in the thresholding. The default value is 128.
5
6.
Morphological image analysis. Binary morphology operations
Replace Value – represents the value used for the replacement of the pixels which are in the thresholding interval.
IMAQ Morphology
Performs basic morphological transformations. All source images must be 8-bit binary images. The connected source image for a morphological transformation must have been created with a border (see IMAQ Create) capable of supporting the size of the structuring element as 3X3 (border=1), 5X5(border=2) and so on.
Square/Hexa (Square) – specifies whether to treat the pixel frame as square or hexagonal during the transformation. The default is square.
Image Src – is the reference to the source (input) image.
Image Dst – is the reference to the destination image. If it is connected, it must be the same type as the Image Src.
Image Dst Out – is the reference for the destination image.
Operation – specifies the type of morphological transformation procedure to use.
The default is AutoM. You can choose from the following values:
Type Descriere
AutoM
Close
Dilate
Erode
Gradient
Auto median
Dilation followed by an erosion
Dilation
Erosion
Extraction of internal and external contours of a particle
Gradient out
Gradient in
Extraction of exterior contours of a particle
Hit miss
Open
Pclose
Popen
Thick
Thin
Extraction of interior contours of a particle
Elimination of all pixels that do not have the same pattern as found in the structuring element
Erosion followed by a dilation
A succession of seven closings and openings
A succession of seven openings and closings
Activation of all pixels matching the pattern in the structuring element
Elimination of all pixels matching the pattern in the structuring element
6
Digital image processing
IMAQ GrayMorphology
Performs grayscale morphological transformations. All source and destination image types must be the same. The connected source image for a morphological transformation must have been created with a border capable of supporting the size of the structuring element as 3X3 (border=1), 5X5(border=2) and so on.
Square/Hexa (Square) – specifies whether to treat the pixel frame as square or hexagonal during the transformation. The default is square.
Image Scr – is the reference to the source (input) image.
Image Dst – is the reference to the destination image. If it is connected, it must be the same type as the Image Src.
Image Dst Out – is the reference for the destination image.
Operation – specifies the type of morphological transformation procedure to use.
The default is AutoM. You can choose from the following values:
Type
AutoM
Close
Dilate
Erode
Open
PClose
POpen
Description
Auto median
Dilation followed by an erosion
Dilation
Erosion
Erosion followed by a dilation
A succession of seven closings and openings
A succession of seven openings and closings
P r r a c t t i i c e
open a new LabView session create a new project the user interface should be the following:
7
6.
Morphological image analysis. Binary morphology operations
in the diagram window, add the needed components to obtain the following diagram:
8
Digital image processing
load different images and notice the effect of the different thresholds and different morphological operations on these images, for different structuring elements.
open a new LabView session create a new project in the diagram window, add the needed components to obtain the following diagram:
the user interface should be the following:
9
6.
Morphological image analysis. Binary morphology operations
load different images, apply the morphological transformations for different structuring elements and observe their effect.
Q u e s t t i i o n s a n d e x e r r c i i s e s
Except for the morphological transformations studied above, other (more advanced) functions used in the morphological image analysis exist, as e.g.:
- IMAQ Label
- IMAQ Convex
- IMAQ FillHole
- IMAQ RejectBorder
- IMAQ Separation
- IMAQ Skeleton
Study the operation of these functions from the LabView help/IMAQ Vision User
Manual, and implement a LabView Project that uses these functions on a binary image – examining their effect on different images.
A d d i i t t i i o n a l l r r e f f e r e n c e s
[1]. IMAQ Vision for G Reference Manual, National Instruments, 1999
[2]. IMAQ Vision User Manual, National Instruments, 1999
[3]. A. VLAICU, „ Prelucrarea Digitală a Imaginilor ”, editura Albastră, Cluj Napoca, 1997
[4]. G.X. Ritter, J.N. Wilson, „ Handbook of Computer Vision Algorithms in Image
Algebra ”, CRC Press, 2000
[5]. R.C. Gonzales, „ Digital Image Processing ”, Addison Wesley, 1993
[6]. Mathematica software – modulul „ Edge Detection ”
10