Question: Problem 2 Convolution function (45 pts) In class, we discussed the following code segment, where we applied convolution to the image img with the given

 Problem 2 Convolution function (45 pts) In class, we discussed the
following code segment, where we applied convolution to the image img with

Problem 2 Convolution function (45 pts) In class, we discussed the following code segment, where we applied convolution to the image img with the given 55 filter. filter =np.ones ((5,5))(1.0/52) blurred_cat = img. copy () h,w,= img. shape for i in range (2,h2): for j in range (2,w2): for c in range (3): blurred_cat [i,j,c]=np.sum(im[i2:i+3,j2:j+3,c]filter) In file myconv. py, please implement a function myconv to apply convolution to an image with a filter. Note the shapes of the image and filter can vary. In particular, myconv function takes two arguments, an image (a hw3-dimensional numpy array with RGB values) and a filter (a k1k2 2-dimensional numpy array, where both k1 and k2 are odd positive integers), and return another image with the same shape as the imput image. - You need to extract the shape of the input image and filter in the function. - For those pixels too close to the edge to fit the filter around, leave them unchanged. - You can assume h>k1,w>k2. - If you take as input the img and filter in the above code segment, the function should return blurred_cat. - Put your testing code under if name == '_main -_. But only your implemented function will be graded, your testing code won't be graded

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!