21bce7877 Ass9

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

DIGITAL IMAGE PROCESSING

NAME : SAI THANMAY.A

ROLL NO : 21BCE7877

LAB SLOT : L31 + L32

ASSIGNMENT NO : 9
Experiment – 9
Image Segmentation through Edge/Boundary Detection a.
Sobel Edge Detection
b. Canny Edge Detection
c. Laplacian of Gaussian

Aim :
The experiment aims to explore edge and boundary detection
techniques for image segmentation, including Sobel Edge Detection,
Canny Edge Detection, and Laplacian of Gaussian.

Algorithm :
Step 1: Read the image using imread() and display it using imshow().
Step 2: Convert the image to a black and white image using im2bw()
and get its dimensions.
Step 3: Define the starting point for boundary tracing and trace the
boundary using bwtraceboundary().
Step 4: Plot the traced boundary using plot().
Step 5: Apply the Sobel Edge Detection filter using edge() and display
the result using imshow().
Step 6: Apply the Canny Edge Detection filter using edge() and display
the result using imshow().
Step 7: Apply the Laplacian of Gaussian filter using fspecial() and
imfilter() and display the result using imshow().
Program :

%Image Segmentation through Edge/Boundary Detection


I=imread('nature.jpg');
imshow(I) BW=im2bw(I);
imshow(BW) dim=size(BW);
col=round(dim(2)/2)-90;
row=min(find(BW(:,col)));

boundary=bwtraceboundary(BW,[row, col],'N');
imshow(I)
hold on;
plot(boundary(:,2),boundary(:,1),'g','LineWidth',1); title("Edge
Detection")

BW1=edge(BW,'sobel');
BW2=edge(BW,'canny');
figure imshow(BW1)
title('Sobel Filter')
figure imshow(BW2)
title('Canny Filter')
f=I;
w=fspecial('log',[3 3],0.5);
filtered_img=imfilter(f,w,'replicate');
imshow(filtered_img); title("Laplacian
of gaussian")
Original Image

Output :
Black and White Image
Conclusion :
In conclusion, this experiment explored different techniques for edge
and boundary detection in image segmentation, including Sobel Edge
Detection, Canny Edge Detection, and Laplacian of Gaussian. Through
a comparative analysis, it was found that each method has its strengths
and weaknesses in accurately identifying edges and boundaries in
images. Sobel Edge Detection is effective in detecting abrupt intensity
changes, Canny Edge Detection is strong in reducing noise and
localizing edges precisely, and Laplacian of Gaussian is robust in
detecting edges at various scales. Understanding these techniques'
performance characteristics offers valuable insights for their application
in various image segmentation tasks.

You might also like