Wednesday, August 28, 2013

Activity 10 - Morphological Operations

This is one of my favorite activity, the morphological operations

There are a lot of morphological operations and it is really convenient to know how to implement them or how they work. Morphological operations are one of the techniques in image processing to enhance our remove details of an image. This is applied especially to binary image which are easy to understand and implemented.


Table 1. Morphological Operations Supported by Matlab lifted from [2]
Operation
Description
'bothat'
Performs the morphological "bottom hat" operation, returning the image minus the morphological closing of the image (dilation followed by erosion).
'branchpoints'
Find branch points of skeleton. For example:
0  0  1  0  0           0  0  0  0  0
0  0  1  0  0  becomes  0  0  0  0  0
1  1  1  1  1           0  0  1  0  0
0  0  1  0  0           0  0  0  0  0
0  0  1  0  0           0  0  0  0  0
Note: To find branch points, the image must be skeletonized. To create a skeletonized image, usebwmorph(BW,'skel').
'bridge'
Bridges unconnected pixels, that is, sets 0-valued pixels to 1 if they have two nonzero neighbors that are not connected. For example:
1  0  0           1  1  0 
1  0  1  becomes  1  1  1 
0  0  1           0  1  1
'clean'
Removes isolated pixels (individual 1s that are surrounded by 0s), such as the center pixel in this pattern.
0  0  0 
0  1  0 
0  0  0
'close'
Performs morphological closing (dilation followed by erosion).
'diag'
Uses diagonal fill to eliminate 8-connectivity of the background. For example:
0  1  0           0  1  0 
1  0  0  becomes  1  1  0 
0  0  0           0  0  0
'dilate'
Performs dilation using the structuring element ones(3).
'endpoints'
Finds end points of skeleton. For example:
1  0  0  0           1  0  0  0
0  1  0  0  becomes  0  0  0  0
0  0  1  0           0  0  1  0
0  0  0  0           0  0  0  0
Note: To find end points, the image must be skeletonized. To create a skeletonized image, usebwmorph(BW,'skel').
'erode'
Performs erosion using the structuring element ones(3).
'fill'
Fills isolated interior pixels (individual 0s that are surrounded by 1s), such as the center pixel in this pattern.
1  1  1 
1  0  1 
1  1  1
'hbreak'
Removes H-connected pixels. For example:
1  1  1           1  1  1 
0  1  0  becomes  0  0  0 
1  1  1           1  1  1
'majority'
Sets a pixel to 1 if five or more pixels in its 3-by-3 neighborhood are 1s; otherwise, it sets the pixel to 0.
'open'
Performs morphological opening (erosion followed by dilation).
'remove'
Removes interior pixels. This option sets a pixel to 0 if all its 4-connected neighbors are 1, thus leaving only the boundary pixels on.
'shrink'
With n = Inf, shrinks objects to points. It removes pixels so that objects without holes shrink to a point, and objects with holes shrink to a connected ring halfway between each hole and the outer boundary. This option preserves the Euler number.
'skel'
With n = Inf, removes pixels on the boundaries of objects but does not allow objects to break apart. The pixels remaining make up the image skeleton. This option preserves the Euler number.
'spur'
Removes spur pixels. For example:
0  0  0  0           0  0  0  0
0  0  0  0           0  0  0  0
0  0  1  0  becomes  0  0  0  0
0  1  0  0           0  1  0  0
1  1  0  0           1  1  0  0
'thicken'
With n = Inf, thickens objects by adding pixels to the exterior of objects until doing so would result in previously unconnected objects being 8-connected. This option preserves the Euler number.
'thin'
With n = Inf, thins objects to lines. It removes pixels so that an object without holes shrinks to a minimally connected stroke, and an object with holes shrinks to a connected ring halfway between each hole and the outer boundary. This option preserves the Euler number. See Algorithms for more detail.
'tophat'
Performs morphological "top hat" operation, returning the image minus the morphological opening of the image (erosion followed by dilation).
In this activity, we will only observe erosion and dilation which is the very basic of morphological operations. The previous table, is worthwhile reading for you to know that there are a lot of morphological operation that you can explore more than this activity.

The results and the images in this activity is very small, ranging from 4-50 pixels, I really dont know how I will present it here, systematically and to make it presentable. Maybe its just that there are so many results. Anyway here are the results by implementing morphological operation to a predescribed binary images as well as structure elements.


Figure 1. 5x5 square (left) and a triangle, base = 4 boxes, height = 3 boxes (right)

Figure 2. A hollow 10×10 square, 2 boxes thick(left), and plus sign, one box thick, 5 boxes along each line (right)


STRUCTURE ELEMENTS

Figure 3. (from left to right) 2×2 ones, 2×1 ones, 1×2 ones, cross(3 pixels long,1 pixel thick), diagonal line(two boxes long)


DILATION (top) EROSION (bottom)

Figure 4 Dilation and erosion following the same order of SE, for the 5x5 square.



Figure 5. Dilation and erosion following the same order of SE, for the triangle


Figure 6.  Dilation and erosion following the same order of SE, for the hollow 10x10 square

Figure 7 Dilation and erosion following the same order of SE, for the cross

Figure 4-7 is the expected results, I will upload the hand drawn some time,
Anyway the obvious result is that the dilation expands the image while the erosion shrinks it accordingly to the Structure element.

References:
[1]AP 186 Handouts.Activity 10 - Morphological Operations. Maricor Soriano 2013
-------------------------------------------------------------------------------------
Self Grade:
8/10

No comments:

Post a Comment