Opening & Closing Nandish Patel
Mathematical Morphology Morphological
Operators are tools for extracting image components that are useful in the representation and description of region shape, such as boundaries, skeletons, and the convex hull.
The operators are
particularly useful for the analysis of binary images and common usages include edge detection, noise removal, image enhancement and image segmentation.
Morphological Operators There are 2 primitive operations that are used by many of the other morphological algorithms. Dilation Erosion
Brief Introduction: Dilation Dilation is useful in bridging gaps in images and expands an image. The basic effect of the operator on a binary image is to gradually enlarge the boundaries of regions of foreground pixels (i.e. white pixels, typically). Thus areas of foreground pixels grow in size while holes within those regions become smaller.
Brief Introduction: Dilation Structuring element B is applied on every
pixel in an Image A. If at least one pixel in the structuring element coincides with a foreground pixel in the image underneath, then the input pixel is set to the foreground value. If all the corresponding pixels in the image are background however, the input pixel is left at the background value.
Example of Dilation
3x3 Structuring Element of all 1’s was used.
Brief Introduction: Erosion Erosion is used for eliminating irrelevant
detail (in terms of size) from a binary image and shrinks an image. The basic effect of the operator on a binary image is to erode away the boundaries of regions of foreground pixels (i.e. white pixels, typically). Thus areas of foreground pixels shrink in size, and holes within those areas become larger.
Brief Introduction: Erosion Structuring element B is applied on every
pixel in an Image A. If for every pixel in the structuring element, the corresponding pixel in the image underneath is a foreground pixel, then the input pixel is left as it is. If any of the corresponding pixels in the image are background however, the input pixel is also set to background value.
Example of Erosion
3x3 Structuring Element of all 1’s was used.
Opening & Closing Opening and Closing are morphological
operators which use the 2 primitive operators, Erosion and Dilation. Opening smoothes the contour of an object, and breaks narrow isthmuses, and eliminates thin protrusions. Closing tends to smooth sections of contours but, unlike opening, it fuses narrow breaks and long thin gulfs, eliminates small holes, and fills gaps in the contour.
Opening Opening is defined as applying Erosion on an Image A with a Structuring Element B and then applying Dilation on the resulting Image with the same Structuring Element B. The Structuring Element can vary according to the results you want generated.
Still Opening… The basic effect of an opening is somewhat like erosion in that it tends to remove some of the foreground (bright) pixels from the edges of regions of foreground pixels. However it is less destructive than erosion in general. The effect of the operator is to preserve foreground regions that have a similar shape to this structuring element, or that can completely contain the structuring element, while eliminating all other regions of foreground pixels.
Effects of Opening Original Image
Eroded Image
Opened Image
Effects of Opening An important use for Opening is to find patterns in Images. Depending on the structuring element, Opening can help find patterns in Images like Circles, Squares, Rectangles etc… The result of Opening depends mostly on the Structuring Element, so it is important to pick a good Structuring Element.
Finding Patterns Original
Opened
A disc shaped Structuring Element with 11 pixels as diameter was used to find the Circles in this Image
Finding Patterns Original
Vertical Lines
Horizontal Lines
Opening with a 3×9 vertically oriented structuring element resulted in Vertical Lines, and Opening with a 9x3 horizontally oriented structuring element resulted in Horizontal Lines.
Salt & Pepper Noise Salt Noise can be reduced using a Opening and a 3x3 square structuring element.
Pepper Noise can not be reduced using Opening. Closing is more suitable for reducing Pepper Noise.
Closing Closing is similar in some ways to dilation in that it tends to enlarge the boundaries of foreground (bright) regions in an image (and shrink background color holes in such regions), but it is less destructive on the original boundary shape. The effect of the operator is to preserve background regions that have a similar shape to this structuring element, or that can completely contain the structuring element, while eliminating all other regions of background pixels
Keep Closing… One of the uses of dilation is to fill in small
background color holes in images, e.g. `pepper' noise. One of the problems with doing this however is that the dilation will also distort all regions of pixels indiscriminately. We can remove some of this effect by Closing. Closing is defined as performing an erosion on the image after the dilation, Closing can also be used to reduce known patterns in an image by using a structuring element.
Effect of Closing Original Image
Closed Image
Examples of Closing Original Image
Closed Image
Original Image contains small and large holes, With a disc shaped Structuring Element using 22 pixel diameter, the smaller holes can be removed.
Salt & Pepper Noise Salt Noise cannot be reduced by Closing.
Pepper Noise can be reduced by Closing.
Project Progress Researched Opening and Closing
as well as Erosion and Dilation in details to get an understanding on the project. Researched the matlab functions imerode() and imdilate(). Made Opening and Closing Functions which use imerode() and imdilate(). Imerode() takes 2 parameters, Image to Erode and the Structuring Element. Imdilate() takes 2 parameters, Image to Dilate and the Structuring Element.
function Opening = func(im, filt) im1 = imerode(im,filt); im2 = imdilate(im1,filt); figure; imshow(im); figure; imshow(im2);
function Closing = func(im, filt) im1 = imdilate(im,filt); im2 = imerode(im1,filt); figure; imshow(im); figure; imshow(im2);
Conclusion Opening and Closing are operators similar to Erosion and Dilation. Opening and Closing are improved versions of Erosion and Dilation because they are less destructive on the images. The results gathered from Opening and Closing depend on how the Structuring Element has been designed.
Now Closed
Any Questions? OR Comments!?