Question: In this exercise, you will implement the Canny edge detector ( without hysteresis thresholding ) . You are required to write each of the functions.

In this exercise, you will implement the Canny edge detector (without hysteresis thresholding). You are
required to write each of the functions. You may not use any of the in-built MATLAB edge detection
functions.
Task 1: Implement Gaussian blur
Write a program that performs Gaussian blur on an input image using the following 55 kernel, where B is
the blurred version of input image A. Show your result on the screen. (Hint: Use imfilter)
B=1159[245424912945121512549129424542]*A
Task 2: Calculate image gradients
Write a program that does the following in order. You should reuse your Task 1 code.
Load an imsge.
Convert it into a grayscale (single channel) image.
Blur the image using a 55 Gaussion filter
Calculate the gradient of the blurred image in the x and y directions using a 33 Sobel filter (Tlint: Recoll
that SobelX and SobelY kermels from your Lecture and do the same thing as Task 1, but with the Sobel filters
insteadj
Check the x and y gradient values (i.e.G, and G,) to make sure ther are correct (Hint: After you hove
apalied the Sobel kernels, you would have gorten the grodients, just plor them using inshow)
Task 3: Calculate gradient magnitude
Extend your program to calculate the gradient magnitude. Gradient magritude G is a function of the
gradients in the x and y directions (G, Gy). Show the gradient magnitude on the screen as a grayscale image
G=Gx2+Gy22
Task 4: Calculate gradient orientation
totend your proeram to cokculate the grasent oriereation as folom:
=arctas(zGx)
You may find the finction oton? useful for this purpose. &Get atand wil return the ongle in radions, If yoy
At this point, you will here 4 arres that should hare coactly the same number ef rows and columen. Your
image arrar holds oripinal image (and the cfore should have 3 dimeroions mhich are rowh, columes, and
colourl. Then there is a Eapcale wersion of the oribinel imuge 12 dmeroioral. Then wou have a thets and a G
Task 5: Non-maxima Suppression and thresholding
Finally eatend your code to perform nan-masima superesion in order to "bin" the edees along the gradiem
orietation. A detaled summery bo provided bere. The idee a wo cere any pisel that is eot greader in terms of
(tent: the beir way to go aboor this is ro ereate on arroy sher holds the ongles mar pou cas monually
calculate in the 8 compass direcniens. Jo hrlp you, you moy ase Dhe informanion below and seme strep-by-step.
instrucnions
Fiow the sbove image is is olesr thor pi and pi both point to the West. If nou get 0, that poists to the Gast if
Fov get p/2, that points so the Nerth. 1 you get -pi/2, that poirs to the Soath
To make ble casc, ivat push them iste the round the frection down, romer than tuke the average.
anglen =|-Q,-34p4,-p2,-p4,Q,p4,pV2,3'pV4,pl : Nelrections in radars
what the ancles mes
If you want to take the "closest", which is more accurate you will need to further divide the angles to be
between N-NW, and then compare theta to decide which to push it to.
Step 1: Your loop will run from the pixel in row 2 until (total rows -1), and from column 2 until (total columns
-1). This means you need two for-loops. Use the nested for loops to run through all elements in theta.. If the
current pixel is not a local maximum, suppress it (set it to zero).
For example, the code below checks the theta for north and west, and we only keep the element which has
the maximum gradient magnitude in the given gradient orientation. You will need to write the code for the
other 6 composs directionsfor \\21sire(theta,1)-1 currentMaq - G(1,\) ; fourrent elenent 11f this 10 the case, you are facing North elseif (theta(1,2)>--p165 theta(1,{)-3*p1/4) brest elseif tthe reat of your code goes here 4 We otarted with 0, so WM5 wi11 be changed to G if it is the naximum VourrentKag >= nesghbouri,end endStep 2: Test your code against your test images and visualise them using imshow:
Step 3: Threshold your NMS results by using imhist to get a histogram that will help you to set it. You can get
the top 10 of this by using the function prctile
Step 4: Show the thresholded result using inshow.
 In this exercise, you will implement the Canny edge detector (without

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!