Homework 2 Due Friday, Oct. 13, 9 a.m. Written: 1. Consider a scalar signal f(x). a) Write the equation describing the continous-domain convolution of this signal by a kernel k1, followed by the convolution of a second kernel k2, that is f * k1 * k2. b) Let G(x) denote a Gaussian function with mean 0 and variance x. Determine the value y (in terms of x) such that f * G(x)*G(x) = f* G(y). 2. Let I(x,y) denote a two-dimension signal (i.e. an image). a) Write the discrete form of the convolution of I by a two-dimensional (sampled) Gaussian kernel H(x), where x denotes the variance in both coordinate directions. b) Show that the Gaussian kernel is separable. That is, show that I*H(x) = I* G(x1) * G(x2) for some x1 and x2. 3. Demonstrate that convolution is commutative. (CS 461 only) 4. Given a box filter of width 2m+1, determine the wavelength of sin wave (in terms of m) that is a) completely removed from a signal b) that is a local maximum in terms of the amount of peak-to-peak signal that is passed by the filter. Compute also the ratio of input peak-to-peak vs. output peak-to-peak signal. Implementation: 1. Implement the Canny edge detection algorithm. Do so as follows: a) Write a function to compute image gradients expressed as magnitude and direction. The form should be: [magnitude,orientation] = EdgeFilter(image, sigma) In this case, sigma is the variance of the Gaussian filter you must use to compute the derivatives. b) Write a non-maximal suppression algorithm of the form newManitudeImage = NonMaximalSuppression(magnitude,orientation) c) Write a hysteresis thresholding algorithm of the form BinaryEdgeImage = HysteresisThreshold(magnitudeImage,minThresh, maxThresh) As suggested above, the output should be a binary image. To demonstrate the algorithm, apply the filter to the "peppers" image by first converting it to gray scale. Create a script Problem1.m that performs each stage of the Canny filter and displays the intermediate results in a separate image. Display the mangnitude image in figure 1, the result of nonmaximal suppression in figure 2, and the final edge image in figure 3. Repeat the computations for Gaussian variance of 1, 2, 4 and 8. You may choose your own thresholds, but you should display the thresholds you use at each scale. Call the intermediate images magx, dirx, newmagx, and binx where x is 1,2,4, or 8 (this is so we can compare your output to what we expect automatically). CS461 Only: 2. Implement a slight variation on the corner detection algorithm described in class. Do it as follows. 1. Compute the gradient image. In this case, the function should be [dx,dy] = Gradient(imageIn,sigmaIn) 2. Compute three images that are (dI/dx)^2, dI/dx * dI/dy, and (dI/dy)^2 3. Apply an averaging filter to these images to accumulate values over a reasonable area (e.g. 15x15). 4. The three images computed above can be viewed as the components of the 2x2 symmetric matrix M at each point in the image. Compute a "cornerness value" for each pixel that is Det(M) - k*trace(M) where k is a parameter you can choose (somewhere around 0.05 seems to work well). 5. Perform non-maximal suppression on this image. 6. Choose a threshold that yields somewhere between 10 and 100 features and display the result by plotting an x at each corner. You should also return the coordinates themselves. Create the complete function as coordsOut = Corners(imageIn, sigmaIn, widthIn, threshold) where: coordsOut is a 2 by n matrix of corner coordinates (each column is a 2x1 vector of location) imageIn is an input gray-scale image sigmaIn is the variance of the Gaussian used to compute the gradient widthIn is the width of the averaging filter threshold is the threshold used to choose the corners to select. Create a script called Problem2.m that executes the Corners function on the peppers gray-scale image using a sigma of 1, 2, and 4, a width of 15, and a threshold of your choice. Extra Credit: (5 pts) Create a version of this function that instead sorts all points after non-maximal suppression and returns the top N based on the value computed in step 4.