5
$\begingroup$

Quick Note: I don't believe this is a subjective question... however if it is I will gladly modify to be more objective

In ImageJ, if I take the FFT of an image, how can I save this new frequency domain image? The goal being that I would like to be able to open it up and take the IFFT.

When I try this, imageJ says you need to have a frequency domain image. This leaves me thinking that whatever information it has about the frequency domain is lost once I save.

My end goal is to take images that I have taken the FFT of from a python script that I am debugging and load them up in imageJ and take the IFFT.

$\endgroup$
5
  • $\begingroup$ What did you save? Did you save both the real and imaginary components of the complex 2D FFT? $\endgroup$
    – hotpaw2
    Nov 1, 2016 at 18:07
  • $\begingroup$ From imageJ I must only be saving the real components. I have not found... how to save the imaginary components. I wonder if it is possible to access this information with imageJ ? $\endgroup$ Nov 1, 2016 at 18:26
  • $\begingroup$ Surely you can view the image in Python. Or convert to a regular image format in Python, then load it in ImageJ. Why do you have to run the IFFT of ImageJ? $\endgroup$
    – Knut Inge
    Sep 20, 2022 at 5:22
  • $\begingroup$ @KnutInge As an alternative form of debugging. Multiple methods of debugging can offer great insight into a problem. $\endgroup$ Sep 22, 2022 at 3:54
  • $\begingroup$ Does ImageJ allow for picking either the real or the imag part of the FFT, save each as two separate images, then load them both into Python/Matlab/… for analysis? $\endgroup$
    – Knut Inge
    Sep 22, 2022 at 4:39

5 Answers 5

2
$\begingroup$

A real image generally is a multichannel (often RGB) stack of real, or integer data. A standard FFT converts each channel into a complex domain image. Which is often not supported in standard formats.

Although complex data types are supported in some languages, I do not know of fully standard complex storage file formats. Which would be nice! Let us start with some basics.

The most simple option is to store them as two different images (for the real/imaginary parts, or amplitude/phase parts), or in two different channels. It probably requires some adjustment in amplitudes, and thus a little additional information.

However, some "niche" formats could be reused. I am thinking about MRI data with a complex appearance in the $k$-space (see Magnitude, real and phase images). The full datasets provided here proposes a two-part format for such complex data, along with Matlab code, which probably could be translated for ImageJ. Description:

The .cfl raw data file is a binary file containing a single contiguous block of array data of dimensions described in the header file. The raw data file is of type complex float (i.e. 32-bit real + 32-bit imaginary), hence the extension .cfl.

The ISMRM Raw Data Format (ISMRMRD) supports complex data. Cris Luengo nicely added that one: The ICS (Image Cytometry Standard) format is capable of storing: [...] images in 8, 16, 32 or 64 bit integer, 32 or 64 bit floating point and floating point complex data

$\endgroup$
3
  • 1
    $\begingroup$ I was afraid of something like that... I find it interesting that there is not a complex storage format. $\endgroup$ Nov 1, 2016 at 18:27
  • 1
    $\begingroup$ There is also the ICS format: en.m.wikipedia.org/wiki/Image_Cytometry_Standard $\endgroup$ Sep 24, 2022 at 16:55
  • $\begingroup$ Perfect, added (with mention), for exhaustivity $\endgroup$ Sep 25, 2022 at 9:52
1
$\begingroup$

A trick would be to use the TIFF format which supports many channels. For each channel in your original image create 2 channels, one for the magnitude and the other for the phase.

TIFF supports 32 bit hence data will be well preserved.

$\endgroup$
3
  • $\begingroup$ Can you provide an example? $\endgroup$ Sep 20, 2019 at 13:37
  • $\begingroup$ I will try later. If I remember to do it. The trick is to predefine the scales (Dynamic Range). $\endgroup$
    – Royi
    Sep 20, 2019 at 18:01
  • $\begingroup$ TIFF supports 64-bit floating-point as well. Making the two channels interleaved would trivialize reading and writing from the image in memory. $\endgroup$ Sep 24, 2022 at 16:53
1
$\begingroup$

This is not a knowledgeable answer, but more of a comment including one possible "how-to" tip with a screen capture of what was done. The FFT was saved as a TIFF; reopened; and ultimately an inverse FFT returned the original image (although not quite - it looks smaller, and it contains two images that I don't know how to interpret - the second image is not shown, but it can be displayed using the ImageJ output windows by sliding the bar at the bottom to the right):

enter image description here

$\endgroup$
1
$\begingroup$

The FFT probably had to be ran on a square image that was padded out, the inverse has returned the padded out image.

$\endgroup$
0
$\begingroup$
  1. As ImageJ is open source, why not just find its FFT call, insert a printf() and grab the data directly?

  2. If ImageJ only presents the FFT magnitude M = sqrt(R^2+I^2), perhaps there is an option within ImageJ that effectively sets either R or I to zero, such that the stored image contains the absolute value of one of them

  3. The sine/cosine terms of the FFT couples with symmetrical/asymmetrical features of the analyzed signal. By carefully manipulating the symmetry/asymmetry of a test image, you should ve able to infer a lot about ImageJs FFT.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.