I’m trying to find a Python library that works equivalently to MATLAB’s freqz2 for image processing, since scipy.signal.freqz only seems to work for 1-D arrays.
Advertisement
Answer
Found an amazing library for plotting the 3D surface of the 2-D FFT called plotly. I leave here the lines of code I used to emulate the same behaviour of freqz2 in Python:
import scipy.fft as fft import plotly.graph_objects as go N = 128 h = fspecial('unsharp', alpha=0.2) H = fft.fftshift(fft.fft2(h, [N, N])) f = fft.fftshift(fft.fftfreq(N)) fig = go.Figure(data=[go.Surface(x=f, y=f, z=np.abs(H))]) fig.show()
The 3D graphs is interactive, and the fspecial function in python I implemented it myself copying what MATLAB does (I can also post it if asked).
Which is the equivalent to MATLAB’s:
h = fspecial('unsharp'); freqz2(h);