/** * Computes a complex-to-complex forward or inverse FFT transform of an * n-dimensional dataset in a certain dimension. By default as many threads as * processors are available are used. By default the real values are scaled if * it is an inverse transform (divided by the amount of pixels in the input * dataset), this way after performing a forward and reverse FFT, the values * will be exactly the same. By default the real values are not scaled if it * is a forward transform (not divided by the amount of pixels in the input * dataset) * * @param data - the complex-valued dataset (FFT performed in-place) * @param dim - the dimension to compute the inverse FFT in * @param forward - true means forward FFT transform, false means inverse FFT * transform * @return - true if successful, false if the dimensionality of the dataset is * not supported by the edu_mines_jtk 1d fft */ final public static <C extends ComplexType<C>> boolean complexToComplex(final RandomAccessibleInterval<C> data, final int dim, final boolean forward) { if (forward) return complexToComplex(data, dim, forward, false); return complexToComplex(data, dim, forward, true); }
/** * Computes a complex-to-complex forward or inverse FFT transform of an n-dimensional dataset in a certain dimension. * By default as many threads as processors are available are used. * * @param data - the complex-valued dataset (FFT performed in-place) * @param dim - the dimension to compute the inverse FFT in * @param forward - true means forward FFT transform, false means inverse FFT transform * @param scale - define if each pixel is divided by the sum of all pixels in the image * @return - true if successful, false if the dimensionality of the dataset is not supported by the edu_mines_jtk 1d fft */ final public static < C extends ComplexType< C > > boolean complexToComplex( final RandomAccessibleInterval< C > data, final int dim, final boolean forward, final boolean scale ) { return complexToComplex( data, dim, forward, scale, Runtime.getRuntime().availableProcessors() ); }
/** * Computes a complex-to-complex forward or inverse FFT transform of an n-dimensional dataset in a certain dimension. * By default as many threads as processors are available are used. * By default the real values are scaled if it is an inverse transform (divided by the amount of pixels in the input dataset), this way after performing a forward and reverse FFT, the values will be exactly the same. * By default the real values are not scaled if it is a forward transform (not divided by the amount of pixels in the input dataset) * * @param data - the complex-valued dataset (FFT performed in-place) * @param dim - the dimension to compute the inverse FFT in * @param forward - true means forward FFT transform, false means inverse FFT transform * @return - true if successful, false if the dimensionality of the dataset is not supported by the edu_mines_jtk 1d fft */ final public static < C extends ComplexType< C > > boolean complexToComplex( final RandomAccessibleInterval< C > data, final int dim, final boolean forward ) { if ( forward ) return complexToComplex( data, dim, forward, false, Runtime.getRuntime().availableProcessors() ); return complexToComplex( data, dim, forward, true ); }
final public static < C extends ComplexType< C > > void complexToComplexForward( final RandomAccessibleInterval< C > data ) { for ( int d = 0; d < data.numDimensions(); ++d ) FFTMethods.complexToComplex( data, d, true ); }
final public static < C extends ComplexType< C > > void complexToComplexInverse( final RandomAccessibleInterval< C > data, final ExecutorService service ) { for ( int d = 0; d < data.numDimensions(); ++d ) FFTMethods.complexToComplex( data, d, false, true, service ); }
final public static < C extends ComplexType< C > > void complexToComplexForward( final RandomAccessibleInterval< C > data, final ExecutorService service ) { for ( int d = 0; d < data.numDimensions(); ++d ) FFTMethods.complexToComplex( data, d, true, false, service ); }
final public static < C extends ComplexType< C > > void complexToComplexInverse( final RandomAccessibleInterval< C > data ) { for ( int d = 0; d < data.numDimensions(); ++d ) FFTMethods.complexToComplex( data, d, false ); }
/** * Computes a complex-to-complex forward or inverse FFT transform of an * n-dimensional dataset in a certain dimension. By default as many threads as * processors are available are used. * * @param data - the complex-valued dataset (FFT performed in-place) * @param dim - the dimension to compute the inverse FFT in * @param forward - true means forward FFT transform, false means inverse FFT * transform * @param scale - define if each pixel is divided by the sum of all pixels in * the image * @return - true if successful, false if the dimensionality of the dataset is * not supported by the edu_mines_jtk 1d fft */ final public static <C extends ComplexType<C>> boolean complexToComplex( final RandomAccessibleInterval<C> data, final int dim, final boolean forward, final boolean scale) { final ExecutorService service = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()); final boolean ret = complexToComplex(data, dim, forward, scale, service); service.shutdown(); return ret; }
final public static < R extends RealType< R >, C extends ComplexType< C > > void realToComplex( final RandomAccessibleInterval< R > input, final RandomAccessibleInterval< C > output, final ExecutorService service ) { FFTMethods.realToComplex( input, output, 0, false, service ); for ( int d = 1; d < input.numDimensions(); ++d ) FFTMethods.complexToComplex( output, d, true, false, service ); }
final public static < C extends ComplexType< C >, R extends RealType< R > > void complexToReal( final RandomAccessibleInterval< C > input, final RandomAccessibleInterval< R > output, final ExecutorService service ) { for ( int d = 1; d < input.numDimensions(); ++d ) FFTMethods.complexToComplex( input, d, false, true, service ); FFTMethods.complexToReal( input, output, 0, true, service ); }
final public static < R extends RealType< R >, C extends ComplexType< C > > void realToComplex( final RandomAccessibleInterval< R > input, final RandomAccessibleInterval< C > output ) { FFTMethods.realToComplex( input, output, 0 ); for ( int d = 1; d < input.numDimensions(); ++d ) FFTMethods.complexToComplex( output, d, true ); }
/** * Compute an ND inverse FFT */ @Override public void mutate(final RandomAccessibleInterval<C> inout) { for (int d = inout.numDimensions() - 1; d >= 0; d--) FFTMethods.complexToComplex(inout, d, false, true, ts .getExecutorService()); }
final public static < C extends ComplexType< C >, R extends RealType< R > > void complexToReal( final RandomAccessibleInterval< C > input, final RandomAccessibleInterval< R > output ) { for ( int d = 1; d < input.numDimensions(); ++d ) FFTMethods.complexToComplex( input, d, false ); FFTMethods.complexToReal( input, output, 0 ); }
final public static < C extends ComplexType< C >, R extends RealType< R > > void complexToRealUnpad( final RandomAccessibleInterval< C > input, final RandomAccessibleInterval< R > output, final ExecutorService service ) { for ( int d = 1; d < input.numDimensions(); ++d ) FFTMethods.complexToComplex( input, d, false, true, service ); FFTMethods.complexToReal( input, output, FFTMethods.unpaddingIntervalCentered( input, output ), 0, true, service ); }
final public static < C extends ComplexType< C >, R extends RealType< R > > void complexToRealUnpad( final RandomAccessibleInterval< C > input, final RandomAccessibleInterval< R > output ) { for ( int d = 1; d < input.numDimensions(); ++d ) FFTMethods.complexToComplex( input, d, false ); FFTMethods.complexToReal( input, output, FFTMethods.unpaddingIntervalCentered( input, output ), 0 ); } }
/** * Computes an ND FFT using FFTMethods */ @Override public void compute(final RandomAccessibleInterval<T> input, final RandomAccessibleInterval<C> output) { // perform a real to complex FFT in the first dimension FFTMethods.realToComplex(input, output, 0, false, ts.getExecutorService()); // loop and perform complex to complex FFT in the remaining dimensions for (int d = 1; d < input.numDimensions(); d++) FFTMethods.complexToComplex(output, d, true, false, ts .getExecutorService()); }
/** * Compute an ND inverse FFT */ @Override public void compute(final RandomAccessibleInterval<C> input, final RandomAccessibleInterval<T> output) { final RandomAccessibleInterval<C> temp = copyOp.calculate(input); for (int d = input.numDimensions() - 1; d > 0; d--) FFTMethods.complexToComplex(temp, d, false, true, ts .getExecutorService()); FFTMethods.complexToReal(temp, output, FFTMethods.unpaddingIntervalCentered( temp, output), 0, true, ts.getExecutorService()); }
FFTMethods.complexToComplex( fft, d, false ); FFTMethods.complexToComplex( fft, d, false );
FFTMethods.complexToComplex( fft, d, false ); FFTMethods.complexToComplex( fft, d, false, true, service );