Answered step by step
Verified Expert Solution
Question
1 Approved Answer
python : 2d convolution by using numpy I used this dog picture and coded it using only numpy. However, in the im_fillter function part, error
python : 2d convolution by using numpy
I used this dog picture and coded it using only numpy. However, in the im_fillter function part, error : the phrase 6
The code is as follows
In [1]: import numpy as np from matplot lib import pyplot as p import cv2 In [2] : def my_imfilter( image, kernel): filtered_image = np.zeros( image. shape) image_padded = np.zeros(( image. shape[0] + 2, image. shape[1] + 2,)) image_padded[1:-1, 1:-1] = image for x in rangel image. shape[1]): for y in range( image. shape[0]): filtered_image[y, x]=(kernel + image_padded[y: yu3, X: X+3] ). sum() print('my_imfilter function in student.py needs to be implemented') return filtered_image In [3] : img = cv2. imread("dog.jpg") image = cv2.cvt Color (img, cv2.COLOR_BGR2RGB) In [4] : kernel = np.array([[0, 1, 0], [1, 0, 1], [0, 1, 0]]) In [5]: filtered_img = my_imfilter( image, kernel) ValueError Traceback (most recent call last)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