Login  Register

Re: Antwort: FFT-Filtering - are non-symmetric masks useful?

Posted by Michael Schmid on Dec 13, 2007; 1:20pm
URL: http://imagej.273.s1.nabble.com/FFT-Filtering-are-non-symmetric-masks-useful-tp3697755p3697758.html

Hi Albert,

maybe you are right that the problem is the FHT (Hartley
transform), but I think that one should be able to get the FFT
coefficients from an FHT.
Anyhow, it seems to me that this does not work as expected.

For example, the power spectrum of a sum of two sine or
cosine functions with different amplitudes looks like the
square of a power spectrum to me. Twice the amplitude gives
16 times the intensity in the power spectrum, not 4 times as I
would expect.
(I used the "raw" power spectrum, not the log-scaled one)

Below is the macro that I use for testing - it creates a sum of
one-dimensional sin and cos functions.

Further, in the "Complex FFT", a sin(x) function does not give
an imaginary result as I would have expected.
Strange enough, when trying a simple sinusoidal function with
different phaseshifts, I always get a real result (apart from
numeric noise in the imaginary channel).

One more point, but this could be resolved more easily:
With FFT Math>Correlate, when correlating an image with itself
and doing no inverse transformation I would expect to get the
unscaled power spectrum, not the log-scaled one.

Below is the macro that I use for testing - it creates a
one-dimensional sin and cos function.

Maybe Joachim Wesner, the FFT/FHT expert in the group, can say
more about this, whether it is a limitation inherent to the
FHT or some more mundane problem?


Michael
________________________________________________________________
// T E S T   M A C R O
newImage("test", "32-bit Black", 256, 256, 1);
pi = 3.1415926536;
f1 = 1*2*pi/256;
f2 = 2*2*pi/256;

for (x=0; x<255; x++) {
   //v = sin(f1*x + pi/8);
   v = sin(f1*x)+0.5*cos(f2*x);
   setPixel(x, 0, v);
}
makeRectangle(0, 0, 256, 1);
run("Copy");
for (y=1; y<256; y++) {
   makeRectangle(0, y, 256, 1);
  run("Paste");
}
run("Select None");

run("FFT Options...", "fft raw fast complex");
run("FD Math...", "image1=test operation=Correlate image2=test  
result=PowerSpectrum");


________________________________________________________________

On 12 Dec 2007, at 23:00, Albert Cardona wrote:

> Joachim, Michael,
>
> Just a note:
>
> As far as I know, ImageJ's "FFT", which is an FHT as Joachim says,
> does not properly replace FFT at all. When trying to rely on it for  
> Cepstrum
> and other uses related to registration we realized how much off it is
> from a proper FFT: a lot.
>
> We use FFT from jfftw.jar wrapper for native fftw libraries, and in  
> their absence,
> the FFT classes from edu_mines_jtk.jar . Using these, results are  
> as analitically
> expected.
>
> There are a few example of its uses in the mpi.fruitfly package of  
> TrakEM2,
> implemented by Stephan Preibisch.
>
> The git repos:
>    http://repo.or.cz/w/trakem2.git
>
> The archived source classes:
>    http://www.ini.uzh.ch/~acardona/piper.php?file=jars/TrakEM2-src.zip
>
> Albert
>
> --
> Albert Cardona
> http://www.mcdb.ucla.edu/Research/Hartenstein/acardona