I have the following 8bit grey scale image:
The 2d FFT of this image, showing the color coded Abs[fft]
values, is:
The code to obtain the FFT image is:
img = Import["https://i.stack.imgur.com/CA0nv.png"];
dimimg = ImageDimensions[img];
rdimimg = Reverse[dimimg];
fft = Fourier[ImageData[img]];
fftRotated = RotateLeft[fft, Floor[Dimensions[fft]/2]];
fftAbsData = Abs[fftRotated];
minc = 140;
myColorTable =
Flatten@{Table[{Blend[{Blue, Green, Yellow, Orange}, x]}, {x,
1/minc, 1, 1/minc}],
Table[{Blend[{Orange, Red, Darker@Red}, x]}, {x, 1/(256 - minc),
1, 1/(256 - minc)}]};
g = Colorize[
ImageResize[Image[fftAbsData], {rdimimg[[1]], rdimimg[[2]]}],
ColorFunction -> (Blend[myColorTable, #] &)];
xfrequencies = (Range[rdimimg[[1]]] - Round[rdimimg[[1]]/2])/
rdimimg[[1]];
yfrequencies = (Range[rdimimg[[2]]] - Round[rdimimg[[2]]/2])/
rdimimg[[2]];
minmaxxf = MinMax[xfrequencies];
minmaxyf = MinMax[yfrequencies];
dy = minmaxyf[[2]] - minmaxyf[[1]];
dx = minmaxxf[[2]] - minmaxxf[[1]];
scaleFactor = 600;
imagefft = ImageResize[g, scaleFactor*{dx, dy}]
Questions:
Now I would like to cut out the red ring and make a backward FFT to see which objects of the original image belong to the high amplitude fft data, seen in red.
How can I cout out a circular region in the fft image?
Even without cutting out a part I am not able to reproduce the original image from fft
:
inverse=Image[InverseFourier[fft]]
gives me:
Why does InverseFourier
not reproduce the original image?
DiskMatrix[{R1, R2}, {n1, n2}] - DiskMatrix[{r1, r2}, {n1, n2}]
. Here,n1
andn2
are the image dimensions,R1
,R2
are the outer radii andr1
, r2` are the inner radii of the annulus. And of course, byInverseFourier
but I expect you knew it already ;) $\endgroup$Chop
, you can see that it works by checking thatimg - Image[Chop@InverseFourier[fft]]
is a completely black image. (Alternately, you can callMax
on the result and check that the largest value is on the order of machine precision, 10^(-16)) $\endgroup$