0% found this document useful (0 votes)
39 views16 pages

Matlab Project

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views16 pages

Matlab Project

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 16

MATLAB PROJECT ON

EDGE DETECTION
ACKNOWLEDGEMENT

We have taken efforts in this project. However, it would not


have been possible without the kind support and help of many
individuals. We would like to extend our sincere thanks to all of
them. First and foremost, we would like to thank Prof. Ankur
Gupta (Director) Model Institute of Engineering and Technology
(MIET) Jammu, and Prof. (Dr.) Ashok Kumar Dean
(Academics) and Head of Department.
As special gratitude we give to our mentor Mrs. Gurpreet and
Shiveta Mam whose contribution in stimulating suggestions and
encouragement which helped us to writing this report. Lastly,
we would like to thank our respected parents who always
encouraged us and taught us to think and workout innovatively
whatsoever be the feel of life.
Our team members-

NAME ROLL NO.


Shriya Manhas 2020a3r009
Simran Choudhary 2020a3t016
Mehak 2020a3r007
Rupali Sharma 2020a3r012
Mitali Abrol 2020a3r010
CONTENT
• Abstract
• Introduction
• Process
• Code
• Output
• References
ABSTRACT

Edge detection is an image processing


technique for finding the boundaries of
objects within images. It works by detecting
discontinuities in brightness. Edge
detection is used for image segmentation
and data extraction in areas such as image
processing, computer vision, and machine
vision.

Common edge detection algorithms include


Sobel, Canny, Prewitt, Roberts, and fuzzy
logic methods.
For edge detection in this project, we take
the help of convolution: Convolution = I * m
where I is the image, m is the mask and *
is convolutional operator. To perform
convolution on an image following steps
are required:
Flip the mask horizontally and then
vertically. This will result in 180-degree
rotation of an image.
1. Slide the mask onto the image such that
every pixel in the image coincides with the
center of the mask atleast once.
2. Multiply the corresponding elements with
the pixel values below it and then add
them.
3.Repeat this procedure until all pixel
values of the image have been calculated
for updation.
INTRODUCTION:

Edge detection is an image processing


technique for finding the boundaries of
objects within images. It works by
detecting discontinuities in brightness.
Edge detection is used for image
segmentation and data extraction in areas
such as image processing, computer
vision, and machine vision.

Approach :

For edge detection, we take the help of


convolution: Convolution = I * m where I is
the image, m is the mask and * is
convolutional operator. To perform
convolution on an image following steps
are required:
1. Flip the mask horizontally and then
vertically. This will result in 180-degree
rotation of an image.
2. Slide the mask onto the image such that
every pixel in the image coincides with
the centre of the mask at least once.
3. Multiply the corresponding elements with
the pixel values below it and then add
them.
4. Repeat this procedure until all pixel
values of the image have been
calculated for updation.
Now, we will take 3×3 mask for the same.
• 3×3 Mask for vertical edges : [1, 0, -1; 1, 0, -
1; 1, 0, -1]
• .
3×3 Mask for horizontal edges : [1, 0, -1; 1,
0, -1; 1, 0, -1]

3×3 Mask for principal diagonal edges : [1, 0,
-1; 1, 0, -1; 1, 0, -1]

• 3×3 Mask for secondary diagonal edges : [1,


0, -1; 1, 0, -1; 1, 0, -1]

We’ll find these edges separately and finally


combine them using max function or mean
function but max function is more accurate for
this.
THE CODE:

I=double(imread('image.jpg'));
In=I;
mask1=[1, 0, -1;1, 0, -1;1, 0, -1];
mask2=[1, 1, 1;0, 0, 0;-1, -1, -1];
mask3=[0, -1, -1;1, 0, -1;1, 1, 0];
mask4=[1, 1, 0;1, 0, -1;0, -1, -1];

mask1=flipud(mask1);
mask1=fliplr(mask1);
mask2=flipud(mask2);
mask2=fliplr(mask2);
mask3=flipud(mask3);
mask3=fliplr(mask3);
mask4=flipud(mask4)
mask4=fliplr(mask4);

for i=2:size(I, 1)-1


for j=2:size(I, 2)-1
neighbour_matrix1=mask1.*In(i-1:i+1, j-1:j+1);
avg_value1=sum(neighbour_matrix1(:));

neighbour_matrix2=mask2.*In(i-1:i+1, j-1:j+1);
avg_value2=sum(neighbour_matrix2(:));

neighbour_matrix3=mask3.*In(i-1:i+1, j-1:j+1);
avg_value3=sum(neighbour_matrix3(:));
neighbour_matrix4=mask4.*In(i-1:i+1, j-1:j+1);
avg_value4=sum(neighbour_matrix4(:));

%using max function for detection of final edges


I(i, j)=max([avg_value1, avg_value2, avg_value3,
avg_value4]);
end
end
figure, imshow(uint8(I))

You might also like