Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Q2.2 Edge detection (20 points) Write a function that finds edge intensity and orientation in an image. Display the output of your function for one
Q2.2 Edge detection (20 points) Write a function that finds edge intensity and orientation in an image. Display the output of your function for one of the given images in the handout. function (img1] = myEdgeFilter(imgo, sigma) The function will input a greyscale image (imgo) and scalar (sigma). sigma is the standard deviation of the Gaussian smoothing kernel to be used before edge detection. The function will output img1, the edge magnitude image. First, use your convolution function to smooth out the image with the specified Gaus- sian kernel. This helps reduce noise and spurious fine edges in the image. Use fspecial to get the kernel for the Gaussian filter. The size of the Gaussian filter should depend on sigma (e.g., hsize = 2 * ceil(3 * sigma) + 1). The edge magnitude image img1 can be calculated from image gradients in the x direction and y direction. To find the image gradient imgx in the r direction, convolve the smoothed image with the c-oriented Sobel filter. Similarly, find image gradient imgy in the y direction by convolving the smoothed image with the y-oriented Sobel filter. You can also output imgx and imgy if needed. In many cases, the high gradient magnitude region along an edge will be quite thick. For finding lines its best to have edges that are a single pixel wide. Towards this end, make your edge filter implement non-maximum suppression, that is for each pixel look at the two neighboring pixels along the gradient direction and if either of those pixels has a larger gradient magnitude then set the edge magnitude at the center pixel to zero. Map the gradient angle to the closest of 4 cases, where the line is sloped at almost 0, 45, 90, and 135. For example, 30 would map to 45 For more details about non-maximum suppression, please refer to the last page of this handout. Your code cannot call on Matlab's edge function, or any other similar functions. You may use edge for comparison and debugging. A sample result is shown in Figure 1. Q2.2 Edge detection (20 points) Write a function that finds edge intensity and orientation in an image. Display the output of your function for one of the given images in the handout. function (img1] = myEdgeFilter(imgo, sigma) The function will input a greyscale image (imgo) and scalar (sigma). sigma is the standard deviation of the Gaussian smoothing kernel to be used before edge detection. The function will output img1, the edge magnitude image. First, use your convolution function to smooth out the image with the specified Gaus- sian kernel. This helps reduce noise and spurious fine edges in the image. Use fspecial to get the kernel for the Gaussian filter. The size of the Gaussian filter should depend on sigma (e.g., hsize = 2 * ceil(3 * sigma) + 1). The edge magnitude image img1 can be calculated from image gradients in the x direction and y direction. To find the image gradient imgx in the r direction, convolve the smoothed image with the c-oriented Sobel filter. Similarly, find image gradient imgy in the y direction by convolving the smoothed image with the y-oriented Sobel filter. You can also output imgx and imgy if needed. In many cases, the high gradient magnitude region along an edge will be quite thick. For finding lines its best to have edges that are a single pixel wide. Towards this end, make your edge filter implement non-maximum suppression, that is for each pixel look at the two neighboring pixels along the gradient direction and if either of those pixels has a larger gradient magnitude then set the edge magnitude at the center pixel to zero. Map the gradient angle to the closest of 4 cases, where the line is sloped at almost 0, 45, 90, and 135. For example, 30 would map to 45 For more details about non-maximum suppression, please refer to the last page of this handout. Your code cannot call on Matlab's edge function, or any other similar functions. You may use edge for comparison and debugging. A sample result is shown in Figure 1
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started