Canny Edge Detection:
The Canny Edge Detector is one of the most commonly used image processing tools, detecting edges in a very
robust manner. It is a multi-step process, which can be implemented on the GPU as a sequence of filters. Many of these
intermediate filters are those I have already asked you to implement for other parts of this assignment! The following
steps are also outlined in various online articles (e.g., Wikipedia (http://en.wikipedia.org/wiki/Canny edge detector))
if you prefer a different treatment.
If you would like to compare your results to a C implementation (or double check that you understand the algo-
rithm), you can download an implementation here: ftp://figment.csee.usf.edu/pub/Edge Comparison/source code/canny.src
Step 0: Convert to Grayscale
There is no reason why you could not do Canny edge detection on a color image, but I encourage you to first
convert the image to grayscale using some sort of RGB→grayscale or RGB→luminance conversion (such as the one
I assigned for this assignment).
Step 1: Noise Reduction
Usually noise reduction implies some sort of blurring operation.... Most people use a Gaussian filter to do this.
One suggestion is to use the following 5 × 5 filter:
Note that this 5 × 5 filter is roughly equivalent to the Gaussian filter I asked you to implement for this assignment,
using a σ ≈ 1.4.
Step 2: Compute Gradient Magnitude and Angle
Compute the derivatives (Dx(x, y) and Dy(x, y)) of the image in the x and y directions. You can do this exactly
the same way I suggested when performing the Sobel filter, i.e., use central differencing using the following 3 × 3
Then compute the gradient magnitude:
D2x(x, y) + D
and the angle of the gradient:
θ = arctan
Compute θ′ by rounding the angle θ to one of four directions 0◦, 45◦, 90◦, or 135◦. Obviously for edges, 180◦ = 0◦,
225◦ = 45◦, etc. This means θ in the ranges [−22.5◦...22.5◦] and [157.5◦...202.5◦] would “round” to θ′ = 0◦. For a
pictoral representation, each edge ta