Professional Documents
Culture Documents
THEORY:
All the derivative masks should have the following properties-
• Opposite sign should be present in the mask.
• Sum of mask should be equal to zero.
• More weight means more edge detection.
1) PREWITT OPERATOR-
Prewitt operator provides us two masks one for detecting edges in
horizontal
direction and another for detecting edges in an vertical direction.
1. VERTICAL EDGE DETECTION
2. HORIZONTAL EDGE DETECTION
Both detections followed the rules of derivative.
2) SOBEL OPERATOR-
Sobel operator is also used to detect two kinds of edges in an
image:
1. VERTICAL DIRECTION
2. HORIZONTAL DIRECTION
The major difference is that in Sobel operator the coefficients of
masks are not fixed and
they can be adjusted according to our requirement unless they do
not violate any property of
derivative masks.
3) LAPLACIAN OPERATOR-
Is also a derivative operator which is used to find edges in an
image.
• Laplacian is a second order derivative mask.
• didn’t take out edges in any particular direction but it take out
edges in following
classification:
• Inward Edges
• Outward Edges
• Positive Laplacian Operator
CODE:
clc
clear all
close all
a=imread('Bird.jpg');
b=rgb2gray(a);
subplot(3,3,1)
imshow(b)
title('Original gray image')
% % SOBEL OPERATOR
m=[-1 -2 -1;0 0 0;1 2 1]
c=conv2(m,b);
subplot(3,3,2)
imshow(c)
title('Horizontal edge detection SOBEL')
m1=[-1 0 1;-2 0 2;1 0 -1]
d=conv2(m1,b);
subplot(3,3,3)
imshow(d)
title('Vertical edge detection SOBEL')
% % PREWITT OPERATOR
m2=[-1 1 -1;0 0 0;1 -1 1]
e=conv2(m2,b);
subplot(3,3,4)
imshow(e)
title('Horizontal edge detection PREWITT operator ')
m3=[-1 0 1;1 0 -1;1 0 -1]
f=conv2(m3,b);
subplot(3,3,6)
imshow(f)
title('Vertical edge detection PREWITT operator')
% % LAPLACIAN OPERATOR
OUTPUT:
EXPERIMENT 8
AIM: Rotation, translation and scaling of an image.
CODE:
clc;
close all;
clear all;
I=imread('Bird.jpg');
%rotate the image
a=imrotate(I,-30,'bilinear','crop');
%resize the image
b=imresize(I,0.5,'nearest');
% translate the image
c=imtranslate(I,[30, 100]);
figure
imshow(a);
title('Rotated Image')
figure
imshow(b);
title('Scaled Image')
figure
imshow(c);
title('Translated Image')
OUTPUT: