[ImageJ-devel] Differences between .fft.FourierTransform and .fft2.FFT

Brian Northan bnorthan at gmail.com
Wed Dec 17 08:42:42 CST 2014

Hi Micheal

I am not entirely familiar with 'FourierTransform' because I've been using
the newer FFT.java class but I think the differences you are seeing are
because 'FourierTransform' has different preprocessing and extension
related settings.

If you look at FourierTransform.java you can see that the constructor you
used in turn calls another constructor


It looks like the 'preprocessing' option defaults to
"relativeExtensionFade' and 'relativeImageExtension' is set to 0.25.

In contrast FFT.java only extends to the nearest 'fast' FFT size and uses a
constant padding strategy.

Keep us up to date on how things are going.  If you manage to get the
tutorial working with the new FFT I think that would be a great addition to
the tutorial.


On Wed, Dec 17, 2014 at 3:54 AM, Michael Ellis <michael.ellis at dsuk.biz>
> I am trying to reproduce example
> imglib2-tutorials Example6c
> https://github.com/imglib/imglib2-tutorials/blob/master/src/main/java/Example6c.java
> using the new net.imglib2.algorithm.fft2.FFT rather than the old
> deprecated net.imglib2.algorithm.fft.FourierTransform
> The original example code does:
>         // compute fourier transform of the template
>         final FourierTransform< FloatType, ComplexFloatType> fft
>                 = new FourierTransform< FloatType, ComplexFloatType>(
>                         template, new ComplexFloatType());
>         fft.process();
>         Img< ComplexFloatType> templateFFT = fft.getResult();
> Which produces an image of size templateFFT minX=0 minY=0 maxX=40 maxY=79
> My new code looks like this:
>             ImgFactory<ComplexFloatType> fftImgFactory = null;
>             try {
>                 fftImgFactory = template.factory().imgFactory(new
> ComplexFloatType());
>             } catch (IncompatibleTypeException ex) {
>                 fftImgFactory = null;
>             }
>             // compute fourier transform of the template
>             Img< ComplexFloatType> templateFFT2 =
> FFT.realToComplex(template, fftImgFactory);
> Which produces an image of size templateFFT2 minX=0 minY=0 maxX=36 maxY=71
> Also it looks like the image produced by the old FourierTransform and new
> FFT differ in that the results are shifted in X and Y.
> Can anyone help?
> In particular I want to achieve the image alignment functionality that is
> done in Example6c.java without using deprecated code.
> Many thanks — Michael Ellis
> _______________________________________________
> ImageJ-devel mailing list
> ImageJ-devel at imagej.net
> http://imagej.net/mailman/listinfo/imagej-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://imagej.net/pipermail/imagej-devel/attachments/20141217/c399b3e5/attachment.html>

More information about the ImageJ-devel mailing list