0% found this document useful (0 votes)
13 views3 pages

Practical 4 - Edge Detection

The document outlines an experiment to implement various edge detection techniques in MATLAB, including Sobel, Prewitt, Roberts, LoG, Zerocross, and Canny. It details the theory behind edge detection, the algorithm for implementation, and provides a MATLAB program for executing these techniques. The results indicate that the Canny edge detector yields the best quality edges, highlighting its advantages in applications such as object detection and medical image analysis.

Uploaded by

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

Practical 4 - Edge Detection

The document outlines an experiment to implement various edge detection techniques in MATLAB, including Sobel, Prewitt, Roberts, LoG, Zerocross, and Canny. It details the theory behind edge detection, the algorithm for implementation, and provides a MATLAB program for executing these techniques. The results indicate that the Canny edge detector yields the best quality edges, highlighting its advantages in applications such as object detection and medical image analysis.

Uploaded by

rashmin.notfound
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Experiment: Write a program for Edge

Detection in MATLAB
Aim
To implement and study different edge detection techniques such as Sobel, Prewitt, Roberts,
LoG, Zerocross, and Canny using MATLAB.

Software Required
• MATLAB
• Image Processing Toolbox

Theory
Edge detection is a fundamental step in digital image processing used to identify boundaries
of objects in an image. Edges are formed where there is a sharp change in intensity.

Different edge detectors use different mathematical approaches:

1. Sobel Operator: Uses weighted gradient masks to detect horizontal and vertical
edges.
2. Prewitt Operator: Similar to Sobel but uses uniform masks.
3. Roberts Operator: Uses 2×2 masks for fast edge detection.
4. LoG (Laplacian of Gaussian): Applies Gaussian smoothing followed by Laplacian
operator.
5. Zerocross Detector: Detects edges by finding zero crossings in the Laplacian output.
6. Canny Detector: Uses multi-stage algorithm for optimal edge detection.

Canny edge detector provides better results compared to other methods due to noise reduction
and edge tracking.

Algorithm
1. Read the input image.
2. Convert the image to grayscale.
3. Convert the image to double format.
4. Apply Sobel edge detector.
5. Apply Prewitt edge detector.
6. Apply Roberts edge detector.
7. Apply LoG edge detector.
8. Apply Zerocross edge detector.
9. Apply Canny edge detector.
10. Display the results.

MATLAB Program
clc;
clear;
close all;

% Read the image


I = imread('[Link]');

% Convert to grayscale if RGB


if size(I,3) == 3
I = rgb2gray(I);
end

% Convert to double
I = im2double(I);

% Display grayscale image


subplot(2,4,1);
imshow(I);
title('Gray Image');

% Sobel Edge Detection


J = edge(I,'sobel');
subplot(2,4,2);
imshow(J);
title('Sobel');

% Prewitt Edge Detection


K = edge(I,'prewitt');
subplot(2,4,3);
imshow(K);
title('Prewitt');

% Roberts Edge Detection


L = edge(I,'roberts');
subplot(2,4,4);
imshow(L);
title('Roberts');

% LoG Edge Detection


M1 = edge(I,'log');
subplot(2,4,5);
imshow(M1);
title('LoG');

% Zerocross Edge Detection


M2 = edge(I,'zerocross');
subplot(2,4,6);
imshow(M2);
title('Zerocross');
% Canny Edge Detection
N = edge(I,'canny');
subplot(2,4,7);
imshow(N);
title('Canny');

Output
The output displays the grayscale image and the corresponding edge-detected images using
different methods in a single figure window.

Result
Thus, edge detection using Sobel, Prewitt, Roberts, LoG, Zerocross, and Canny operators was
successfully implemented in MATLAB. Among them, the Canny operator produced the best
quality edges.

Conclusion
Edge detection helps in identifying important structural features of an image. Different
operators have different advantages. Canny edge detector provides accurate and continuous
edges, while Sobel and Prewitt are simple and fast.

Applications
• Object detection
• Medical image analysis
• Face recognition
• Traffic monitoring
• Computer vision

You might also like