I'm trying to get the fft of an image and then plot the fraq of that fft with using matplotlib. However, this error message:
"ValueError: x and y can be no greater than 2-D, but have shapes (2592,) and (2592, 1, 3)".
I tried to reshape my np.array like so:
import numpy as np
from PIL import Image
import matplotlib.pyplot as plt
import tkinter
from scipy.fftpack import fft, fft2, fftshift
resim = Image.open(r'yeni.jpg')
resim_data = np.asarray(resim)
fourier = fft2(resim_data)
#psd2D = np.abs(fourier)**2
plt.figure()
plt.semilogy(abs(fourier).astype(np.uint8))
plt.title('fourier transform fraq')
plt.show()
ERROR MESSAGE BLELOW:
Traceback (most recent call last):
File "myfrouier.py", line 21, in
plt.semilogy(abs(fourier).astype(np.uint8)) File
"/home/aybarsyildiz/.local/lib/python3.6/site-packages/matplotlib/pyplot.py",
line 2878, in semilogy return gca().semilogy(*args, **kwargs)
File "/home/aybarsyildiz/.local/lib/python3.6/site-packages/matplotlib/axes/_axes.py", line 1844, in semilogy l = self.plot(*args, **kwargs) File "/home/aybarsyildiz/.local/lib/python3.6/site-packages/matplotlib/init.py", line 1810, in inner return func(ax, *args, **kwargs)
File "/home/aybarsyildiz/.local/lib/python3.6/site-packages/matplotlib/axes/_axes.py", line 1611, in plot for line in self._get_lines(*args, **kwargs):
File "/home/aybarsyildiz/.local/lib/python3.6/site-packages/matplotlib/axes/_base.py", line 393, in _grab_next_args yield from self._plot_args(this, kwargs) File "/home/aybarsyildiz/.local/lib/python3.6/site-packages/matplotlib/axes/_base.py", line 370, in _plot_args x, y = self._xy_from_xy(x, y) File "/home/aybarsyildiz/.local/lib/python3.6/site-packages/matplotlib/axes/_base.py", line 234, in _xy_from_xy "shapes {} and {}".format(x.shape, y.shape)) ValueError: x and y can be no greater than 2-D, but have shapes (2592,) and (2592, 1, 3)
y
is(2592, 1, 3)
, you need a 2-D array – yatu