I’m not getting the same result here:
Python:
def compute_fft_simple(image):
# Load the image and convert to grayscale
img = image.convert('L')
# Convert image to numpy array
img_array = np.array(img)
# Compute the 2-dimensional FFT
fft_result = np.fft.fft2(img_array)
magnitude_spectrum = np.abs(fft_result)
G’MIC
to_gray
+fft
a[-2,-1] c
100%,100%,100%,1,cabs(I#-1)
rm.. log.
And yet, I think these output are the same with smaller images:
>>> import numpy
>>> a=numpy.mgrid[:5,:5][0]
>>> a
array([[0, 0, 0, 0, 0],
[1, 1, 1, 1, 1],
[2, 2, 2, 2, 2],
[3, 3, 3, 3, 3],
[4, 4, 4, 4, 4]])
>>> fft_result=numpy.fft.fft2(a)
>>> fft_result
array([[ 50. +0.j , 0. +0.j , 0. +0.j ,
0. +0.j , 0. +0.j ],
[-12.5+17.20477401j, 0. +0.j , 0. +0.j ,
0. +0.j , 0. +0.j ],
[-12.5 +4.0614962j , 0. +0.j , 0. +0.j ,
0. +0.j , 0. +0.j ],
[-12.5 -4.0614962j , 0. +0.j , 0. +0.j ,
0. +0.j , 0. +0.j ],
[-12.5-17.20477401j, 0. +0.j , 0. +0.j ,
0. +0.j , 0. +0.j ]])
>>> magnitude_spectrum=numpy.abs(fft_result)
>>> magnitude_spectrum
array([[50. , 0. , 0. , 0. , 0. ],
[21.26627021, 0. , 0. , 0. , 0. ],
[13.1432778 , 0. , 0. , 0. , 0. ],
[13.1432778 , 0. , 0. , 0. , 0. ],
[21.26627021, 0. , 0. , 0. , 0. ]])
$ 5,5,1,1,y +fft a[-2,-1] c 100%,100%,100%,1,cabs(I#-1) rm..
What’s going on?