$29
Submit your solutions in a pdf or doc file on MarkUs, along with your code. Include images of your output. You can use built-in functions from OpenCV, Numpy, Scipy, or Matlab...etc, unless it is stated that you should write your own. For each piece of code, specify the question to which it corresponds.
1. [2.5 points] Write your own function that implements the correlation (for grayscale or color images and 2D filters) between an input image and a given correlation filter. The function must take as input: an input image ‘I’, a filter ‘f’, and a string ‘mode’, that can either be ‘valid’, ‘same’ or ‘full’. The output must match what is specified by ‘mode’.
2. [1 point] How would you use your function from part A to calculate the convolution between a filter and an image?Use your function from question 1 to convolve iris.jpg with a Gaussian filter σ x = 3 , σ y = 5 , use ‘mode’ = ‘same’.
3. [1 point]Is convolution a commutative operation (f*g =? g*f)? Is correlation a commutative operation? Briefly Explain.
4. [1 point] Is the horizontal derivative. ∂G(x,y)/∂x , of a Gaussian filter G a separable filter? Explain.
5. [1 point] Given a n × n image, I, and m × m filter, h, what is the computational cost of computing h • I if h is not separable? What is the computational cost if h is separable?
6. [1 point]Construct two different separable filters, such that when added, the result is a separable filter.
7. [1 point] Apply the derivative of Gaussian filter and Laplacian of Gaussian filter to portrait.jpg, show your results.
8. [1 point]Detect waldo.jpg in whereswaldo.jpg using correlation (use built-in methods). Your output should show whereswaldo.jpg with a rectangle around waldo.
9. [1 point]How does Canny edge detection work? In your explanation, state the purpose of each step.
10. [ 0.5 point] Briefly explain why the zero crossings of Laplacian of Gaussian can be used to detect edges (Hint: Laplacian is like second derivatives in 2D)
11. [1 point]Use Canny Edge detection on portrait.jpg, adjust the parameters to get rid of the details from the background.