AIR UNIVERSITY ISLAMABAD
COMPUTER APPLICATION IN ENGINEERING
DESIGN
PROJECT REPORT
EDGE DETECTION USING
MATLAB AND PYTHON
SUBMITTED BY SUBMITTED TO
MUHAMMAD USAMA Dr. MUHAMMAD
AMEER HABIB
December 22, 2019
December 22, 2019
1 ABSTRACT
Edge detection identifies points in a digital image where the image bright-
ness changes sharply or has discontinuities with the help of mathematical
methods.Sobel and prewitt operator were supposed to used in image pro-
cessing, particularly within edge detection algorithms,The quality of edge
detection depends on a lot of factors such as illumination, density of edges
in the scene and noise. Huge search space is another problem with most of
the existing operators. The task for edge detection is time consuming and
memory exhausting if done without optimization.
2 INTRODUCTION
Edge detection is a fundamental tool in image processing and computer vi-
sion, particularly in the area of feature detection and feature extraction,
which aims at identifying points in a digital image at which the image
brightness change sharply.
Edge detection is also called high frequency spatial filtering which is
used to highlight the boundaries of different object in an image and hides
the homogeneous background.
Sobel filter is used in image processing particularly within edge detec-
tion algorithms. The sobel operator is based on convolving the ii image
with a small, separable and integer valued filter in horizontal and vertical
direction.
Edge detection refers to the process of identifying and locating sharp
discontinuities in an image. The discontinuities are abrupt change in pixel
intensity which characterize boundaries of an object in a scene. Classical
method of edge detection involves convolving an image with an operator
a (2-D filter), which is constructed to be sensitive to large gradient in an
image while returning values of 0 in uniform regions.
1
3 THE PRINCIPLE OF EDGE DETECTION
In digital image, the so-called edge is a collection of the pixels whose gray
value has a step or roof change, and it also refers to the part where the
brightness of the image local area changes significantly. When we observe
the objects, the clearest part we see firstly is edge and line. According to
the composition of the edge and line, we can know the object structure.
Therefore, edge extraction is an important technique in graphics processing
and feature extraction.
4 METHODOLOGY
The methodology used here to detect Edge in this image is by Sobel Fil-
tering. It’s a method to find the Edge pixels in an image. It’s a gradient
approach in edge detection. Edges are pixels in an image which carry im-
portant information in an image.
Another methodology used is The Prewitt Edge filtering. it is use to
detect edges based applying a horizontal and verticle filter in sequence.
Both filters are applied to the image and summed to form the final result.
The two filters are basic convolution filters of the form: Horizontal Filter.
Verticle Filter.
The Prewitt Edge filter is use to detect edges based applying a horizon-
tal and verticle filter in sequence. Both filters are applied to the image and
summed to form the final result. The two filters are basic convolution filters
of the form: Horizontal Filter. Verticle Filter
5 OBJECTIVE
To detect the edges of the image for better vision using sobel edge detection
filter.
6 ALGORITHM
Edge detection algorithm aims to extract boundaries in the image provided
based on sudden changes or discontinuities; the difference in brightness
values is a good example.
Edges in an image are the portion where there’s a rapid change in in-
tensity.
2
The algorithm works by sliding a filter, or kernel, that can detect edges
over the image to find where the edges are.
The kernel is some real valued matrix, often a 3 by 3 matrix.
The Kernels we are using are :
Prewitt :
1 0 -1
1 0 -1
1 0 -1
Sobel:
-1 -2 -1
0 0 0
1 2 1
There isn’t much difference between the images produced using these
filters.
7 PSEUDO CODE
• Read image you want to test for edge detection.
• Define Byte Array to store input image data.
• Convert byte array into 2D matrix(M) to perform testing.
• Apply sobel and prewitt filter on matrix (M) one by one.
• Store output data in to another Byte array.
• Display output image.
3
8 CONCLUSION
If we test both of these filters there are a few situations that affect both of
our tests.it is difficult to pick one edge detection operator for every situ-
ation. in simpler images, the Sobel and Prewitt operators performed bet-
ter.Though Prewitt technique is similar to Sobel but there is difference of
spectral response. Sobel have slightly superior noise-suppression charac-
teristics, an important issue when dealing with derivatives.So next time i
wll always prefer sober over prewitt filter.
In complicated test cases, these operators will fail miserably in that case
we need to use some better filters which can perform better in complicated
cases.