Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

[ Question 6 ] Edge Detection ( 5 0 marks ) In this question, the goal is to implement a rudimentary edge detection process that

[Question 6] Edge Detection (50 marks)
In this question, the goal is to implement a rudimentary edge detection process that uses a derivative of Gaussian, through a series of steps. For each step (excluding step 1) you are supposed to test your implementation on the provided image, and also on one image of your own choice. Include the results in your report.
Step I - Gaussian Blurring (10 marks): Implement a function that returns a 2D Gaus- sian matrix for input size and scale \sigma . Please note that you should not use any of the existing libraries to create the filter, e.g. cv2.getGaussianKernel(). Moreover, visualize this 2D Gaussian matrix for two choices of \sigma with appropriate filter sizes. For the visualization,
3
you may consider a 2D image with a colormap, or a 3D graph. Make sure to include the color bar or axis values.
Step II - Gradient Magnitude (10 marks): In the lectures, we discussed how partial derivatives of an image are computed. We know that the edges in an image are from the sudden changes of intensity and one way to capture that sudden change is to calculate the gradient magnitude at each pixel. The edge strength or gradient magnitude is defined as:
g(x,y)=|f(x,y)|=qgx2+gy2
where gx and gy are the gradients of image f(x,y) along x and y-axis direction respectively.
Using the Sobel operator, gx and gy can be computed as:
101121 gx=202f(x,y)andgy=000f(x,y)
101121
Implement a function that receives an image f (x, y) as input and returns its gradient g(x, y) magnitude as output using the Sobel operator. You are supposed to implement the convolu- tion required for this task from scratch, without using any existing libraries.
Step III - Threshold Algorithm (20 marks): After finding the image gradient, the next step is to automatically find a threshold value so that edges can be determined. One algorithm to automatically determine image-dependent threshold is as follows:
1. Let the initial threshold \tau 0 be equal to the average intensity of gradient image g(x, y),
as defined below:
Phj=1 Pwi=1 g(i, j)\tau 0= h\times w
where h and w are the height and width of the image under consideration.
2. Set iteration index i =0, and categorize the pixels into two classes, where the lower class consists of the pixels whose gradient magnitudes are less than \tau 0, and the upper class contains the rest of the pixels.
3. Compute the average gradient magnitudes mL and mH of lower and upper classes, respectively.
4. Set iteration i = i +1 and update threshold value as: \tau i = mL + mH
2
5. Repeat steps 2 to 4 until |\tau i \tau i1|<=\epsi is satisfied, where \epsi ->0; take \tau i as final threshold and denote it by \tau .
4
Once the final threshold is obtained, each pixel of gradient image g(x, y) is compared with \tau . The pixels with a gradient higher than \tau are considered as edge point and is represented as white pixel; otherwise, it is designated as black. The edge-mapped image E(x, y), thus obtained is:
(255, if g(x, y)>=\tau 0, otherwise
Implement the aforementioned threshold algorithm. The input to this algorithm is the gra- dient image g(x, y) obtained from step II, and the output is a black and white edge-mapped image E(x, y).
Step IV - Test (10 marks): Use the image provided along with this assignment, and also one image of your choice to test all the previous steps (I to III) and to visualize your results in the report. Convert the images to grayscale first. Please note that the input to each step is the output of the previous step. In a brief paragraph, discuss how the algorithm works for these two examples and highlight its strengths and/or its weaknesses.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Case Studies In Business Data Bases

Authors: James Bradley

1st Edition

0030141346, 978-0030141348

More Books

Students also viewed these Databases questions