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] ]) 
img = imread("download.jpg") 

channels = [] 
for channel in range(3): 
    result = convolve(img[:,:,channel], laplaceMask) 

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



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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.