# How can I find the transform function, amplitude and frequency response of a digital filter in python?

I have applied a laplace filter mask to an image and now I want to find the amplitude and freqency response of a laplacian filter: [[1,1,1], [1,-8,1], [1,1,1] ]. I know I need to first find the transfer function, however, I am unable to do this as well programatically in python.

Here is the code I have currently:

from matplotlib.pyplot import imread
import matplotlib.pyplot as plt
from scipy.ndimage.filters import convolve
import numpy as np
import cv2 as cv

laplaceMask = np.array([ [1,1,1], [1,-8,1], [1,1,1] ])

channels = []
for channel in range(3):
channels.append(result)

img = np.dstack((channels[0], channels[1], channels[2]))

plt.imshow(img)
plt.show()



Assuming each element is the filter coefficients for the R, G, and B channels (I do not know if this is indeed the case here), you can get the frequency response of each channel using scipy.signal.freqz:

scipy.signal.freqz(c, 1, v)


Where c is the filter coefficients and v is the signal data for that channel.