Adsip Lab (Ec-18021) : Session 2020-2021
Adsip Lab (Ec-18021) : Session 2020-2021
Adsip Lab (Ec-18021) : Session 2020-2021
SESSION 2020-2021
LAB REPORTSUBMITTED
By
Theory:
Prewitt operator is used for edge detection in an image. It detects two types of edges
Horizontal edges
Vertical Edges
Edges are calculated by using difference between corresponding pixel intensities of an image.
All the masks that are used for edge detection are also known as derivative masks. Because as
we have stated many times before in this series of tutorials that image is also a signal so
changes in a signal can only be calculated using differentiation. So that’s why these operators
are also called as derivative operators or derivative masks.
All the derivative masks should have the following properties:
-1 0 1
-1 0 1
-1 0 1
Above mask will find the edges in vertical direction and it is because the zeros column in the
vertical direction. When you will convolve this mask on an image, it will give you the vertical
edges in an image.
Horizontal Direction
-1 -1 -1
0 0 0
1 1 1
Above mask will find edges in horizontal direction and it is because that zeros column is in
horizontal direction. When you will convolve this mask onto an image it would prominent
horizontal edges in the image.
MATLAB Code:
clc;
close all;
input_image = imread('flower.jpg’);
for i = 1:size(input_image, 1) - 2
for j = 1:size(input_image, 2) - 2
% Gradient approximations
Gx = sum(sum(Mx.*input_image(i:i+2, j:j+2)));
Gy = sum(sum(My.*input_image(i:i+2, j:j+2)));
end
end
K = edge(input_image,'Prewitt');
figure, imshow(K);
title('Edge detected using inbuilt commands');
Output:-
Original Image
Filtered Image
Edge Detected Image
Result:
Successfully verified and detected the edges of a colored image using Prewitt
operators.
.