Digital Image Processing
Assignment 5
Submitted by:
Student Name: Syed Saad Ali Shah
Enrolment No.: 01-134-171-075
Class and Section: BSCS-7A
Submitted to: Dr. Sumaira Kausar
Department of Computer Science
BAHRIA UNIVERSITY, ISLAMABAD
Assignment#5: Segmentation Basics in Image Processing
Question:
Apply appropriate Sobel filter on the given image to calculate the magnitude and angle
image. Justify the resultant image.
0 0 0 0 0 0
10 10 10 20 20 20
0 0 0 0 0 0
0 20 0 10 200 0
0 20 0 200 10 0
0 20 200 0 0 10
Solution:
Gx Gy
The magnitude of this vector is given by:
Apply zero paddings for border values
32 40 51 71 80 63
20 0 20 20 0 40
32 0 20 258 330 261
63 40 272 579 311 410
80 282 510 28 565 284
63 402 261 568 284 14
The magnitude of this vector is given by:
Gradient Angle:
72 -90 79 82 -90 -72
0 0 0 0 0 0
-18 0 90 -36 -92 -32
18 -90 -54 -45 -135 -1
0 -45 -50 45 135 39
-18 -6 -58 46 51 45
Justification:
We get two outputs images for magnitude and angle. Results show that there are sharp changes in the
intensity values. The magnitude image shows abrupt changes. Values are very large, so, we will apply a
threshold and say that value greater then that is a certain edge and lesser values than the threshold will be
assigned zero. The magnitude image will show edges in the images as we applied Sobel filters in the Matlab
also for edge detection in the realtime also.
The angled image helps us to depict the direction of the edge in a particular image. The orientation of
the edge is given by inverse tan of Gx over Gy, if we take gradient result from Gy and Gx and divide them and
take inverse tan of that it will give the value which will say in which orientation in the image that pixel is. And
that will be very helpful in finding the edges of structures and objects.