Post by David M GaunttThe instruction below describe how to perform a Fourier Transform on your
image, and get the phase of the Fourier transform. This may not be what
your are trying to do, however.
1) Select the command "Process/FFT/FFT Options…". Select the "Complex
Fourier Transform" option.
2) With your image open, select "Process / FFT / FFT". This will produce a
2 image stack containing the real and imaginary componts of the FT.
3) Display the "Real" image in the stack, and then select "File/Save As/Text
image…". Save the file and name it "Real.txt".
4) Display the "Imaginary" image in the stack, and then select "File/Save
As/Text image…". Save the file and name it "Imaginary.txt".
5) Open Excel, and Import the Real.txt file into Excel as tab delimited text.
6) Import the Imaginary.txt file into Excel as tab delimited text.
7) Create a new Excel spreadsheet, and save it as an Excel spreadsheet named
"Phase.xls" (or Phase.xlsx").
=ATAN2(Real.txt!A1,Imaginary.txt!A1)
9) Copy this formula into the rest of the cells of the new spreadsheet. If
your real and imaginary images are 128x128 pixels, then copy into the
first 128 rows and 128 columns.
10) Save phase.xls, then save a copy as a text file as "phase.txt".
11) In ImageJ, select "File / Import / Text Image…" to import "phase.txt".
You have now opened the phase image, with the phase in radians.
That could be made into a macro and save all the file transfer to excel.
Warning - Warning - Warning - Warning - Warning - Warning -
I am not sure the result is correct, so could somebody with some sample data
please check? Maybe this needs some quadrant swapping? Not sure.
I am also not sure if the operands of the atan2 function in excel match the
ones in the macro function.
//---------------
setBatchMode(true);
a=getTitle();
run("FFT Options...", "fft complex");
run("FFT");
selectWindow("Complex of "+a);
run("Duplicate...", "title=phase");
w=getWidth();
h=getHeight();
imag=newArray(w);
for (y=0;y<h;y++){
selectWindow("Complex of "+a);
setSlice(2);
for(x=0;x<w;x++){
imag[x]=getPixel(x,y);
}
selectWindow("phase");
for(x=0;x<w;x++){
putPixel(x,y, atan2(getPixel(x,y), imag[x]));
}
}
setBatchMode(false);
selectWindow("phase");
run("Enhance Contrast", "saturated=0.0");
//---------------
Cheers
Gabriel
--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html