I wanted to see the phase of the image in my hand, but while doing this, I realized that the phase of the image was 3-dimensional, so plt.implot does not process. chat gpt said that this was an error because it consists of complex numbers, the size of phase_spectrum is as follows (1640, 1080, 2)
image_hsv = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)
value_channel_float = np.float32(value_channel)
dft = cv2.dft(np.float32(value_channel_float), flags=cv2.DFT_COMPLEX_OUTPUT)
dft_shift = np.fft.fftshift(dft)
magnitude_spectrum = 20*np.log(cv2.magnitude(dft_shift[:,:,0], dft_shift[:,:,1]))
phase_spectrum = np.angle(dft_shift)
The output of
cv2.dftis a two-dimensional matrix with two channels: one for real and one for imaginary. However, both channels are floats and not like one real and one imaginary. Hence, better to use this:A demonstration of taking this:
Results:
You would need to adjust the FFT using cv2 before going with the typically FFT calculations. I recommend just using numpy...