obat aborsi wonogiri wa 081336238223 jual obat aborsi cytotec asli di wonogir...
ip6_final.pdf
1. 20BEC001 AADITYA DARAKH EXP6 IMAGE PROCESSING 2ECDE51
Objective: To realize edge detection algorithms in MATLAB.
clc;
close all;
clear all
z=imread("AADI_IMAGE.jpeg");
z=rgb2gray(z);
1. Generate a 3x3 mask for detecting vertical edges, horizontal edges, principal diagonal edges and
secondary diagonal edges and write a MATLAB code to detect these edges. Plot the results and
comment on them.
h1=[1,1,1;2,2,2;-1,-1,-1];
h45=[-1,-1,2;-1,2,-1;2,-1,-1];
v1=[-1,2,-1;-1,2,-1;-1,2,-1];
v45=[2,-1,-1;-1,2,-1;-1,-1,2];
figure(1),
subplot(151);g1=imfilter(z,h1);imshow(g1);xlabel('horizontal');
subplot(152);g2=imfilter(z,h45);imshow(g2);xlabel('h+45');
subplot(153);t1=imfilter(z,v1);imshow(t1);xlabel('vertical');
subplot(154);t2=imfilter(z,v45);imshow(t2);xlabel('v+45');
1
2. 2. Apply the following edge detectors on an image and observe their effect on the resultant image. Note
your observations. Sobel Prewitt Roberts log Canny
a=imread("AADI_IMAGE.jpeg");
z=rgb2gray(a);
prewitt=[-1,-1,-1;0,0,0;1,1,1];prewittv=[-1,0,1;-1,0,1;-1,0,1];
sobel=[-1,-1,2;-1,2,-1;2,-1,-1];sobelv=[-1,0,-1;-2,0,0;1,1,1];
sobeld1=[0,1,2;-1,2,-1;-1,2,-1];sobeld2=[-2,-1,0;-1,0,1;0,1,2];
prewittd1=[0,1,1;-1,0,1;-1,-1,0];prewittd2=[-1,-1,0;-1,0,-1;0,1,1];
LOG=[0,0,-1,0,1;0,-1,-2,-1,0;-1,-2,16,-2,-1;0,-1,-2,-1,0;0,0,-1,0,0];
figure(2),
subplot(241);g1=imfilter(z,prewitt);imshow(g1);title('prewitt');
subplot(242);g2=imfilter(z,prewittv);imshow(g2);title('prewitt+v');
subplot(243);g3=imfilter(z,sobel);imshow(g3);title('sobel');
subplot(244);g4=imfilter(z,sobelv);imshow(g4);title('sobelv');
subplot(245);g5=imfilter(z,sobeld1);imshow(g5);title('sobeld1');
subplot(246);g6=imfilter(z,sobeld2);imshow(g6);title('sobeld2');
subplot(247);g7=imfilter(z,prewittd1);imshow(g7);title('prewittd1');
subplot(248);g8=imfilter(z,prewittd2);imshow(g8);title('prewittd2');
3. Analyze the effect of thresholding for edge detection.
figure(),
l1=imfilter(z,LOG);imshow(l1);xlabel('LoG')
2
7. 4. For the filters listed in example 2, write a MATLAB code to perform edge detection without using the
inbuilt MATLAB function. You may follow the following steps:
figure(),
subplot(141);k1=edge(z,"sobel");imshow(k1);title('sobel')
subplot(142);k2=edge(z,"prewitt");imshow(k2);title('prewitt')
subplot(143);k3=edge(z,"roberts");imshow(k3);title('roberts')
subplot(144);k4=edge(z,"canny");imshow(k4);title('canny')
7