Login  Register

Re: Rephrased FFT Question

Posted by bnorthan on Mar 21, 2014; 12:02pm
URL: http://imagej.273.s1.nabble.com/Rephrased-FFT-Question-tp5007000p5007030.html

Dedicated Java code is for sure the way to go.  In this case FFTJ is
already dedicated Java code.  The problem was the overhead in calling the
plugin.  Since the script was written in Python it is actually possible to
import and access java directly.

The first (inefficient) implementation of the Macro

IJ.run("FFTJ Script", "real=TimeProfile imaginary=<none> complex344=[Single
> Precision] fft=forward fourier=[At (0,0,0)] show_power_spectrum")
> spectrum_plus=IJ.getImage()
> spectrum_pix=spectrum_plus.getProcessor().getPixels()
>

 This actually can be easily reworked by using the java interfaces directly

transformer= SinglePrecFFT3D(timeprofile.getStack(), None)
> transformer.fft()
> spectrum_plus=transformer.toImagePlus(ComplexValueType.POWER_SPECTRUM,
> FourierDomainOrigin.AT_ZERO );
> spectrum_pix=spectrum_plus.getProcessor().getPixels()
>

I updated the "macro" (perhaps it should be called a script) and it should
be much faster now

https://github.com/bnorthan/RogueImageJPlugins/blob/master/FFTJ_scriptable/macros/Time_Macro.py

The source code for FFTJ is provided with the plugin

http://rsb.info.nih.gov/ij/plugins/fftj.html

By inspecting it one can see which java interfaces are available and play
with the different ways of presenting the output (real and complex parts,
phase spectrum, power spectrum, etc.)



On Fri, Mar 21, 2014 at 6:31 AM, Doube, Michael <[hidden email]> wrote:

> On 21/03/14 10:22, Herbie wrote:
> > Dedicated Java-code
> > could considerably speed-up the processing.
>
> +1 to that: macros are very slow at doing pixel-by-pixel calculations.
> Experience shows that you will get some orders of magnitude speed-up by
> implementing your algorithm in Java rather than macro. (and some orders of
> magnitude more if it's amenable to being shifted onto the GPU)
>
>
>
> <http://www.rvc.ac.uk>
>
> This message, together with any attachments, is intended for the stated
> addressee(s) only and may contain privileged or confidential information.
> Any views or opinions presented are solely those of the author and do not
> necessarily represent those of the Royal Veterinary College.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html