In trying to replicate an optical Fourier transform within Matlab I did the following:
I loaded this 512x512 image as "dot512r":
Then did:
>> whos dot512r Name Size Bytes Class Attributes dot512r 512x512x3 786432 uint8 >> bwimg=rgb2gray(dot512r); >> whos bwimg Name Size Bytes Class Attributes bwimg 512x512 262144 uint8 >> ftimg=fft2(bwimg); >> figure >> imshow(log(fftshift(ftimg))/10.0);
Which results in this image (so far all's good):
Then I did the inverse fft and displayed it like this:
>> iftimg=ifft2(ftimg); >> imshow(iftimg);
Which resulted in the following image, in which I've marked the anomalies with red arrows. I can accept the two small pixel "errors" at the upper and lower left of the white bar, but the large anomaly at the upper left of the image has me perplexed. The same anomaly appeared in several other shapes that I did with 512x512 images.
I don't get what I'm doing wrong.
bwimg
doesn't have these anomalies? Can you also confirm thatimag(iftimg)
is zero? – Oliver Charlesworth