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

Michael Ellis michael.ellis at dsuk.biz
Wed Dec 17 02:54:13 CST 2014


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






More information about the ImageJ-devel mailing list