Opening & Closing

Download as pdf or txt
Download as pdf or txt
You are on page 1of 25

Opening & Closing

Nandish Patel
Mathematical Morphology
ƒ Morphological ƒ The operators are
Operators are tools particularly useful for
for extracting image the analysis of binary
components that are images and common
useful in the usages include edge
representation and detection, noise
description of region removal, image
shape, such as enhancement and
boundaries, image segmentation.
skeletons, and the
convex hull.
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 ƒ function Opening = func(im, filt)
as well as Erosion and Dilation in ƒ im1 = imerode(im,filt);
details to get an understanding on ƒ im2 = imdilate(im1,filt);
the project.
ƒ Researched the matlab functions ƒ figure;
imerode() and imdilate(). ƒ imshow(im);
ƒ Made Opening and Closing ƒ figure;
Functions which use imerode() ƒ imshow(im2);
and imdilate().
ƒ Imerode() takes 2 parameters, ƒ function Closing = func(im, filt)
Image to Erode and the
Structuring Element. ƒ im1 = imdilate(im,filt);
ƒ Imdilate() takes 2 parameters, ƒ im2 = imerode(im1,filt);
Image to Dilate and the ƒ figure;
Structuring Element. ƒ 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!?

You might also like