I tried to Fourier decompose my image using FFT and reconstruct it back using IFFT. While I did this, I noticed something peculiar:
The first image is the regular one, and the second is the image I constructed by re-combining the DFT:
[g, map]=imread("skull.png");
gdft=fft2(g);
f=ifft2(gdft);
subplot(1,2,1)
imshow(g,map)
subplot(1,2,2)
imshow(f)
As you can see, I applied the function and the inverse successively which means there should technically be no change in the image. Why is there such a noticeable change then? I think there is a loss of information on the relative magnitudes of gray values to some extent.
Maybe relevant details:
- The program was written in Matlab
- The image is 16x16 grayscale in nature
imshow
does something different for integer (your g) and floating-point (your f) images. Useimshow(f,[0,255])
. $\endgroup$g
is an index into the color map... you should dog = ind2rgb(g,map);
before processing it. This will likely give you an RGB image rather than a gray-scale image, so then dog = rgb2gray(g);
. You can now displayimshow(g)
, and computef=ifft2(fft2(g))
, and see thatf-g
is small everywhere. $\endgroup$uint8
image. $\endgroup$