Hi all,
I’m having difficulties getting a 2 or 3D FFT using Imglib2, the example scripts’ functions have been deprecated and so I’m a little confused on how to approach the problem. The code I have so far produces an imagej which is neither the same size or half the size of the original image. It looks to be an FFT but with the top and bottom half switched and the left half of the FFT missing.
Code so far please advise!
File file = new File( "Segment.tif" );
InputStream is = getClass().getResourceAsStream("Single.tif");
Opener opener = new Opener();
ImagePlus input = opener.openTiff(is, "Input");
//input.show();
Img< UnsignedByteType > image = ImagePlusAdapter.wrap(input);
ImgFactory< ComplexFloatType > imgFactory = new ArrayImgFactory< ComplexFloatType >();
Img< ComplexFloatType > fft = imgFactory.create( new long[]{ 1024, 1024, 3 }, new ComplexFloatType(0,0) );
Img< ComplexFloatType > output = imgFactory.create( new long[]{ 1024, 1024, 3 }, new ComplexFloatType(0,0) );
//final RandomAccess< UnsignedByteType > r = image.randomAccess();
//final RandomAccess< UnsignedByteType > r = image.randomAccess();
output = FFT.realToComplex(image,output.factory());
FFT.complexToComplexInverse((RandomAccessibleInterval<ComplexFloatType>) output.randomAccess(),1);
//output = FFT.realToComplex(image.randomAccess(),output.randomAccess());
ImageJFunctions.show( output );
Thanks
Craig