LAB 3
MORPHOLOGY
Source Code
|
|
|
|
|
|| Lab2 ||
Lab3 ||
Lab4 ||
Lab5 ||
Lab6 ||
Lab7 ||
Lab8 ||
Back to Main Menu
________________________________________________________________________________________________________________________
Aim of this lab:
The aim of this laboratory session is to
familiarize you with MATLAB's morphological operations erode and
dilate.
________________________________________________________________________________________________________________________
At the beginning, we were ask to perform
the dilation and erosion operation on our own image. Before doing this, we first
convert out image into grey scale and threshold it.
The following are the results of my images after applying the dilation and
erosion operation.
Figure4 and Figure5 is the dilation and erosion of my grey scale
image with a circular structuring element of size 4 respectively..
MATLAB Command:
g = rgb2gray(im);
%convert image to grey scale
bw = g > 75;
%thresh image, thresh = 75
object = circularstruct(4);
%set circular structuring element of size 4
im_dilate = imdilate(bw,object);
%dilate my image
im_erode = imerode(bw,object); %erode
my image
imshow(im_dilate);
%display dilated image
imshow(im_erod);
%display eroded image
Figure1: My
grey scale image
Figure2:
Histogram of my image
Figure3: My
image thresholded at the value of 75
Figure4:
Dilation of my image
Figure5:
Erosion of my image
Then we applied the opening and closing operations on the image.
Closing operation is an operation of dilation followed by erosion. Whereas, the
opening operation is an operation of erosion followed by dilation.
2 different options have been carried out to apply the opening and closing
operations on the image. One is with a circular structuring element and the
other one is a rectangular structuring element. Figure6 and Figure7
below are the opening and closing of my image.
To make things more interesting, we applied open-close (Figure8) and
close-open(Figure9) operation as well.
Operations with a circular structuring element of size 4
MATLAB Command:
object =
circularstruct(4);
%set circular structuring element of size 4
im_open = imopen(bw,object);
%open
im_close = imclose(bw,object);
%close
im_openclose = imclose(im_open,object);
%open-close
im_closeopen = imopen(im_close,object);
%close-open

Figure6:
Open
Figure7: Close

Figure8:
Open-close
Figure9:
Close-open
Operations with a rectangular
structuring element with height = 2 and width = 4

.jpg)
The next task of this lab was to write a
MATLAB function called locatelandmarks.m. This function will locate the 4
corners of a SURF form and returnt the coordinates of the 4 corners, topleft,
topright, bottomleft and bottomright. This function will also detect if the form
is upside down. Testing was done with a few SURF form with different sizes.
surf01 and surf02 are forms which is slightly smaller than the other surf forms.
Whereas surf11 is a form which is upside down. The locatelandmarks function was
able to detect all the 4 corners of all these forms including those which size
is halved (Figure26) and warning ("Form is Upside Down") appears if the
form is upside down (Figure11).

Figure14:
Surf01
Figure15:
[tl tr bl br] = locatelandmarks(surf1);

Figure16: Surf02
Figure17: [tl tr bl br] =
locatelandmarks(surf2);

Figure18: Surf05
Figure19: [tl tr bl br] =
locatelandmarks(surf5);

Figure20: Surf06
Figure21: [tl tr bl br] =
locatelandmarks(surf6);

Figure22: Surf10
Figure23: [tl tr bl br] =
locatelandmarks(surf6);

Figure24: Surf11 (Upside down)
Figure25: [tl tr bl br] =
locatelandmarks(surf11);Figure26: Surf01 (Half size)
Figure27:
[tl tr bl br] =
locatelandmarks(surf1resize);

Written
by Geoffrey Liau
Last updated: 15th April 2005
liauc01@student.uwa.edu.au