Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Q2.1 Convolution (20 points) Write a function that convolves an image with a given convolution filter function [img1] = myImageFilter(imgo, h) As input, the function
Q2.1 Convolution (20 points) Write a function that convolves an image with a given convolution filter function [img1] = myImageFilter(imgo, h) As input, the function takes a greyscale image (imgo) and a convolution filter stored in matrix h. The output of the function should be an image imgl of the same size as img0 which results from convolving imgo with h. You can assume that the filter h is odd sized along both dimensions. You will need to handle boundary cases on the edges of the image. For example, when you place a convolution mask on the top left corner of the image, most of the filter mask will lie outside the image. One solution is to output a zero value at all these locations, the better thing to do is to pad the image such that pixels lying outside the image boundary have the same intensity value as the nearest pixel that lies inside the image. You can call Matlab's function to pad array. However, your code can not call on Matlab's imfilter, conv2, convn, filter2 functions, or any other similar functions. You may compare your output to these functions for comparison and debugging. It is better to vectorize this function. Examples and meaning of vectorization can be found here. Specifically, try to reduce the number of for loops that you use in the function as much as possible
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