Fourier Transform

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Fourier Transform

Sara_24
Hi
Is there any command in ImageJ to calculate the Fourier transform of images
with the size of non-power of two?

Best regards,
Sara



--
Sent from: http://imagej.1557.x6.nabble.com/

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Fourier Transform

Herbie
Good day,

did you try "ImageJ >> Process >> FFT >> FFT Options..."?

If this doesn't suit your needs then please tell us why.

Regards

Herbie


:::::::::::::::::::::::::::::::::::::
Am 05.12.19 um 18:47 schrieb Sara_24:

> Hi
> Is there any command in ImageJ to calculate the Fourier transform of images
> with the size of non-power of two?
>
> Best regards,
> Sara
>
>
>
> --
> Sent from: http://imagej.1557.x6.nabble.com/
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Fourier Transform

Curtis Rueden-2
In reply to this post by Sara_24
Hi Sara,

You can do it with ImageJ Ops. Here is an example Groovy script that
performs a lowpass filter in Fourier space:

--------
  #@ OpService ops
  #@input Img image
  #@input Double (value=10) radius
  #@output Img result

  import net.imglib2.type.numeric.real.FloatType
  import net.imglib2.util.Util

  lowpass = { fft, radius ->
    pos = new long[fft.numDimensions()]
    long[] origin = [0, 0]
    long[] origin2 = [0, fft.dimension(1)]
    cursor = fft.localizingCursor()
    while (cursor.hasNext()) {
      cursor.fwd()
      cursor.localize(pos)
      dist = Util.distance(origin, pos)
      dist2 = Util.distance(origin2, pos)
      if (dist > radius && dist2 > radius)
        cursor.get().setZero()
    }
  }

  // Perform fft of the input.
  fft = ops.filter().fft(image)

  // Filter it.
  lowpass(fft, radius)

  // Reverse the FFT.
  result = ops.run("create.img", image, new FloatType())
  ops.filter().ifft(result, fft)
--------

ImageJ Ops is part of ImageJ2, and included as part of Fiji.

Regards,
Curtis

--
Curtis Rueden
Software architect, LOCI/Eliceiri lab - https://loci.wisc.edu/software
ImageJ2 lead, Fiji maintainer - https://imagej.net/User:Rueden
Have you tried the Image.sc Forum? https://forum.image.sc/



On Thu, Dec 5, 2019 at 12:22 PM Sara_24 <[hidden email]> wrote:

> Hi
> Is there any command in ImageJ to calculate the Fourier transform of images
> with the size of non-power of two?
>
> Best regards,
> Sara
>
>
>
> --
> Sent from: http://imagej.1557.x6.nabble.com/
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Fourier Transform

Michael Schmid-3
In reply to this post by Sara_24
Hi Sara,

the standard ImageJ Process>FFT command works with images of any size.
The image is padded with a constant value (equal to the average pixel
value) to the next power of two.

For the Fourier-domain filter operations, the image is padded to a power
of two by taking the border as a mirror.
Only the Process > FD Math operations need square input images where the
side length is a power of two.


Michael
________________________________________________________________
On 05.12.19 18:47, Sara_24 wrote:

> Hi
> Is there any command in ImageJ to calculate the Fourier transform of images
> with the size of non-power of two?
>
> Best regards,
> Sara
>
>
>
> --
> Sent from: http://imagej.1557.x6.nabble.com/
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Fourier Transform

Herbie
In reply to this post by Sara_24
Dear Sara,

the options mentioned by you mainly depend on what you want to obtain (see
below).

Independently from these options, ImageJ *will* transform images that have
side-lengths that are not a power of two. (Just try it!)

In general and classically, the Fourier-transformation of digitized images
with side-lengths that are not a power of two can be performed following two
approaches:

1. Using the DFT (Discrete Fourier Transformation)
This approach doesn't show the speed profit of the FFT-algorithm (Fast
Fourier Transformation). In other words, it is comparably slow. (The classic
FFT requires images with side-lengths that are a power of two.)
Here
<https://sites.google.com/site/piotrwendykier/software/parallelfftj>
you find an implementation of the Fourier-transformation for ImageJ (plugin)
that uses the FFT-algorithm for images with side-lengths that are a power of
two and the DFT-algorithm for images with side-lengths that are not a power
of two.

2. Padding (embedding)
Images with side-lengths that are not a power of two are padded to the next
size with side-lengths that are a power of two. In other words, the small
image is embedded in an image support that has side-lengths that are a power
of two. This new support is previously filled with the mean value of the
small image.
As Michael pointed out already, this approach is used by ImageJ.*
(There is a different way of embedding that I prefer. It uses windowing and
embedding in an empty support. If you prefer this common approach, I can
provide a windowing plugin for ImageJ.)


The options you've mentioned (in fact their naming is far from reasonable):

1. FFT window
You get an 8bit result that is the Fourier-Power Spectrum with the spectral
values (gray-values) logarithmically scaled.

2. Raw power spectrum
You get a 32bit result that is the Fourier-Power Spectrum.

3. Fast Hartley Transform
For the time being, forget about this option.

4. Complex Fourier Transform
You get a 32bit stack (consisting of two slices) that represents the
complex-valued Fourier Transform. The first slice is the real part and the
second slice is the imaginary part of the complex-valued Fourier Transform.

The question remains, what you need for your purposes.


Please feel free to ask, if you have further questions.

Regards

Herbie

==========================================
*
ImageJ doesn't centrally embed the small image but puts it at the top left
of the new support. This doesn't make any difference for Power Spectra but
it does introduce a linear phase which has considerable impact on the
complex-valued Fourier spectrum.
If you need the complex-valued Fourier spectrum without this effect you need
to do the correct embedding yourself.

==========================================
Am 08.12.19 um 10:17 schrieb Sara_24:

> Hi Herbie,
>
> would you please tell me which of FFT options do the FFT of images of
> non-power of two size? I use Fiji and as FFT options it has only FFT
> Window,
> Raw power Spectrom, Fast Hartley transform, and complex Fourier transform.
> Which one do the FFT of images of non-power of two size?
>
> Best regards,
> Sara



--
Sent from: http://imagej.1557.x6.nabble.com/

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