1D Fourier transform in macro

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
20 messages Options
Reply | Threaded
Open this post in threaded view
|

1D Fourier transform in macro

Ludovic Pinier
Hi everyone,

I would like to perform a Fourier transform on a profile, and nest it in an ImageJ macro.
I already saw that it is quite new (July 2014) that 1D transform is more easily accessible through FHT.transform1D
I am OK with the macro built-in commands, but not with more sophisticated things.

Does anyone has an example how to nest such function in a macro?

This is to perform direct MTF evaluation from the profile (resolution), because my targets are circular and I can't use the slanted edge method provided in already existing plugins.

Best regards,
Ludovic

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

Re: 1D Fourier transform in macro

Herbie-4
Ludovic,

where does the profile come from?

If it comes from an available image, then take the profile by an area
selection of one pixel height and crop the image to this line. Finally
take the FFT of this line image but take care that the "FFT Options" are
set "Raw power spectrum" & "Do forward transform". What you get is the
1D-Power spectrum of the line image that, of course, is smeared in
f_y-direction. (You may wish to consider the central line selection from
it.)

If the profile is given as numbers, then try to import them as text-image.

Be aware that the MTF is generally understood as the modulus of the
Fourier transform of the point-spread function. That said, you have to
take the square root of the power spectrum.

You may put together a macro by using the macro recorder.

HTH

Herbie

::::::::::::::::::::::::::::::::::::::::
On 23.09.14 16:36, Ludovic Pinier wrote:

> Hi everyone,
>
> I would like to perform a Fourier transform on a profile, and nest it
> in an ImageJ macro. I already saw that it is quite new (July 2014)
> that 1D transform is more easily accessible through FHT.transform1D I
> am OK with the macro built-in commands, but not with more
> sophisticated things.
>
> Does anyone has an example how to nest such function in a macro?
>
> This is to perform direct MTF evaluation from the profile
> (resolution), because my targets are circular and I can't use the
> slanted edge method provided in already existing plugins.
>
> Best regards, Ludovic
>
> -- 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: 1D Fourier transform in macro

Ludovic Pinier
In reply to this post by Ludovic Pinier
Thanks you Herbie,

I thought about that, but unfortunately it is not sufficient for my need. What I get is a single colored pixel in the raw spectrum window. All the others are perfectly black.
At the moment, I extract the profile with ImageJ, and then export to QtiPlot or SciDaVis. I would like to have a nicer, more automated tool.

Thanks anyway,
Ludovic

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

Re: 1D Fourier transform in macro

Michael Schmid
Hi Ludovic,

almost any raw power spectrum in ImageJ will have a single bright pixel at the origin, dominating everything else by more than an order of magnitude. This pixel corresponds to the DC offset, i.e., the average pixel value of the image (it is the square of the average pixel value multiplied by the width of the FFT raised to a power of 4).

To avoid this, you can use a 32-bit image where the average pixel value is zero (subtract the mean pixel value before doing the FFT).
Or adjust Brightness&Contrast - but you may have to move the 'Maximum' slider very much to the left.
Or set that single pixel to zero (e.g. select it with the Wand and use Process>Math>Set) and then use Auto Brightness&Contrast.

Anyhow, I agree that a 1D FFT in the macro would be nice, just that it is a bit of work (one should also have a Windowing function, e.g. selectable between 'none', 'Hamming' and 'Hann'). It would just need someone to do it...

Michael
________________________________________________________________
On Sep 24, 2014, at 10:36, Ludovic Pinier wrote:

> Thanks you Herbie,
>
> I thought about that, but unfortunately it is not sufficient for my need. What I get is a single colored pixel in the raw spectrum window. All the others are perfectly black.
> At the moment, I extract the profile with ImageJ, and then export to QtiPlot or SciDaVis. I would like to have a nicer, more automated tool.
>
> Thanks anyway,
> Ludovic

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

Re: 1D Fourier transform in macro

Ludovic Pinier
In reply to this post by Ludovic Pinier
Thanks for the tricks,

but it is to perform double check of a device calibration, and I  would avoid changing the brightness and contrast of the produced pictures.

There is the Jtransforms library to perform the Fourier transform, written in pure Java. I expect it can be run within ImageJ; and also the "call" built-in function in the macro language to call it. Does anyone have experience with calling external libraries in a macro?

Sincerely,
Ludovic

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

Re: 1D Fourier transform in macro

Herbie-4
Ludovic,

you wrote that "What [you] get is a single colored pixel in the raw
spectrum window."

Does this mean that you are using color images?

Although ImageJ is able to Fourier-transform color images, it is not
what you should do.

Instead, if necessary split your color images and convert each of your
line images to 32bit float before you perform the transform. The dynamic
range of this number format should be sufficient for your purpose, i.e.
you get represented the high Fourier-spectral value at the origin (the
DC) and the low values at higher spatial frequencies. If you want to see
the latter, just adjust Brightness&Contrast as suggested by Michael
Schmid. Brightness&Contrast doesn't change the Fourier-spectral data,
only the way it is displayed.

I also suggest to remove the mean from the line image, as it was pointed
out by Michael Schmid. It doesn't really harm your signals. Windowing is
another important issue.

In any case you should know what Fourier transformation really means. If
not, you may end up with results that may pose more problems then they
solve..

Presently, I see no reason for another tool or FFT-approach.

You said that you want to get the MTF (of some optics I guess) but what
do you want to do with it?

Best

Herbie

::::::::::::::::::::::::::::::::::::::::
On 24.09.14 11:19, Ludovic Pinier wrote:

> Thanks for the tricks,
>
> but it is to perform double check of a device calibration, and I
> would avoid changing the brightness and contrast of the produced
> pictures.
>
> There is the Jtransforms library to perform the Fourier transform,
> written in pure Java. I expect it can be run within ImageJ; and also
> the "call" built-in function in the macro language to call it. Does
> anyone have experience with calling external libraries in a macro?
>
> Sincerely, Ludovic
>
> -- 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: 1D Fourier transform in macro

Ludovic Pinier
In reply to this post by Ludovic Pinier
Herbie,

the pictures I work with are 16bits unsigned grey level from a CT machine (raw format). No color.
And using a Fourier transform is the method described in the standard applying to CT I use (ASTM E-1695). This standard also prevents to remove the mean or alter the contrast/brightness. To be standard-compliant, profile (the "Edge Spread Function") is mandatory. You are only allowed to frequency-filter it, and remove aberrant points. Even the Fourier transform sampling has to be compliant with the standard criteria.
Concerning the Fourier transform, I am used to manipulate time-frequency transforms, but not to deal with the programming aspects.
Last, my reason is that the tool built in the machine is not accurate.
And the "slanted edge method" plugin is inappropriate for the geometry of my targets (which are also defined according to the standard: material, shape and size).
The standard requires a line profile, and the slanted edge produces an integration of the profile along the edge.
I could use this plugin with 1pixel-wide areas, but ,that means I need to rotate the image; and even if is an as-accurate-as-possible transformation, it is an interpolation that produces a calculated image. It is not the direct capture from the sensor anymore. That is also the reason why the slanted edge method was introduced in the ISO12233. But unfortunately, the target definition in this standard is inappropriate for my use.

I know your suggestions could definitely help, but they don't apply to my need.

Best regards,
Ludovic

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

Re: 1D Fourier transform in macro

Francis Burton-3
Dear Ludovic,

I have used simple DFT code in these situations with perfectly acceptable performance - in my case to obtain power spectra of fluorescence intensity signals from z profiles of confocal image stacks.

The code is available here:

http://nayuki.eigenstate.org/page/how-to-implement-the-discrete-fourier-transform

It also has the benefit, at 11 or so lines of code, of being more easily understandable.

Does this help at all?

Francis Burton
University of Glasgow
________________________________________
From: ImageJ Interest Group [[hidden email]] on behalf of Ludovic Pinier [[hidden email]]
Sent: 25 September 2014 08:07
To: [hidden email]
Subject: Re: 1D Fourier transform in macro

Herbie,

the pictures I work with are 16bits unsigned grey level from a CT machine (raw format). No color.
And using a Fourier transform is the method described in the standard applying to CT I use (ASTM E-1695). This standard also prevents to remove the mean or alter the contrast/brightness. To be standard-compliant, profile (the "Edge Spread Function") is mandatory. You are only allowed to frequency-filter it, and remove aberrant points. Even the Fourier transform sampling has to be compliant with the standard criteria.
Concerning the Fourier transform, I am used to manipulate time-frequency transforms, but not to deal with the programming aspects.
Last, my reason is that the tool built in the machine is not accurate.
And the "slanted edge method" plugin is inappropriate for the geometry of my targets (which are also defined according to the standard: material, shape and size).
The standard requires a line profile, and the slanted edge produces an integration of the profile along the edge.
I could use this plugin with 1pixel-wide areas, but ,that means I need to rotate the image; and even if is an as-accurate-as-possible transformation, it is an interpolation that produces a calculated image. It is not the direct capture from the sensor anymore. That is also the reason why the slanted edge method was introduced in the ISO12233. But unfortunately, the target definition in this standard is inappropriate for my use.

I know your suggestions could definitely help, but they don't apply to my need.

Best regards,
Ludovic

--
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: 1D Fourier transform in macro

Ludovic Pinier
In reply to this post by Ludovic Pinier
Dear Francis,

thanks a lot. With only 11 lines of code, I will implement this directly in the macro.
No matter the performance, it is not a huge amount of data!

best regards,
Ludovic

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

Re: 1D Fourier transform in macro

Herbie-4
In reply to this post by Ludovic Pinier
Ludovic,

I must admit that I'm confused!

First you wrote:
"This is to perform direct _MTF_ evaluation from the profile"

Now you write:
"It is for _CT_ (reconstruction)"

You also wrote:
"What I get is a single _colored_ pixel"

Now you write:
"16bits unsigned _grey_ level"

If you are indeed seeking to reconstruct images from CT projections (not
profiles) then there exist several methods to do so. I'm quite familiar
with CT but not with formal standards and norms.

One way of reconstructing images from projections is by first
Fourier-transforming all projections (you need at least n * PI/2
projections, where n is the number of pixels of the properly sampled
projections). The resulting 1D Fourier-spectra are then combined to give
a 2D spectrum by properly rotated superposition of the 1D spectra. This
2D spectrum is to be corrected by the so-called rho-filter to compensate
its 1/f_r amplitude characteristic. Finally the resulting 2D spectrum is
Fourier-retransformed and results in the desired image.

Principally you should be able to compute all steps by use of ImageJ and
perhaps you will even find an appropriate ImageJ-plugin.

In any case, the FFT must lead to complex-valued spectra. Power spectra
make no sense in this application.

Good luck

Herbie

::::::::::::::::::::::::::::::::::::::::
On 25.09.14 09:07, Ludovic Pinier wrote:

> Herbie,
>
> the pictures I work with are 16bits unsigned grey level from a CT machine (raw format). No color.
> And using a Fourier transform is the method described in the standard applying to CT I use (ASTM E-1695). This standard also prevents to remove the mean or alter the contrast/brightness. To be standard-compliant, profile (the "Edge Spread Function") is mandatory. You are only allowed to frequency-filter it, and remove aberrant points. Even the Fourier transform sampling has to be compliant with the standard criteria.
> Concerning the Fourier transform, I am used to manipulate time-frequency transforms, but not to deal with the programming aspects.
> Last, my reason is that the tool built in the machine is not accurate.
> And the "slanted edge method" plugin is inappropriate for the geometry of my targets (which are also defined according to the standard: material, shape and size).
> The standard requires a line profile, and the slanted edge produces an integration of the profile along the edge.
> I could use this plugin with 1pixel-wide areas, but ,that means I need to rotate the image; and even if is an as-accurate-as-possible transformation, it is an interpolation that produces a calculated image. It is not the direct capture from the sensor anymore. That is also the reason why the slanted edge method was introduced in the ISO12233. But unfortunately, the target definition in this standard is inappropriate for my use.
>
> I know your suggestions could definitely help, but they don't apply to my need.
>
> Best regards,
> Ludovic
>
> --
> 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: 1D Fourier transform in macro

Emanuele Martini
In reply to this post by Ludovic Pinier
but imagine to pass the data to some other software specialized in calculation like, for example, matlab?
I think that in matlab is a one line code calculate the fft and the inverse fft.

Emanuele Martini
Image Analys at Ifom-IEO research Campus - Milan -
Image Analyst @Ifom-IEO research campus -MI-
Reply | Threaded
Open this post in threaded view
|

Re: 1D Fourier transform in macro

Michael Schmid
In reply to this post by Herbie-4
Hi Herbie, Ludovic,

to me it looks like Ludovic wants to do a prodecure as described here:

 http://www.irss.ca/documents/CODES%20&%20STANDARDS_02-28-08/ASTM%20Standards/PDF/E1695.PDF

The procedure is essentially determining the one-dimensional point spread function (PSF) from the derivative of the image of an edge, and then taking the Fourier transform of the PSF to find the modulation transfer function (MTF).

So it is really just the Fourier transform of the PSF that is needed.

For that purpose, I agree with Ludovic that no background should be subtracted.

So I tried creating a line with a PSF-like function, replicated it to get a 32-bit square image with a size of 2^n, and ran FFT on it. The raw power spectrum does not give a single pixel in the center but rather a short streak. Then one can do 'Swap Quadrants', run Math>Square Root, select a rectangle of only the first row and do a profile. This profile should be the FFT required for converting the PSF into the MTF.

So one can do it without doing a 1D FFT.


Michael
________________________________________________________________
On Sep 25, 2014, at 11:14, Herbie wrote:

> Ludovic,
>
> I must admit that I'm confused!
>
> First you wrote:
> "This is to perform direct _MTF_ evaluation from the profile"
>
> Now you write:
> "It is for _CT_ (reconstruction)"
>
> You also wrote:
> "What I get is a single _colored_ pixel"
>
> Now you write:
> "16bits unsigned _grey_ level"
>
> If you are indeed seeking to reconstruct images from CT projections (not profiles) then there exist several methods to do so. I'm quite familiar with CT but not with formal standards and norms.
>
> One way of reconstructing images from projections is by first Fourier-transforming all projections (you need at least n * PI/2 projections, where n is the number of pixels of the properly sampled projections). The resulting 1D Fourier-spectra are then combined to give a 2D spectrum by properly rotated superposition of the 1D spectra. This 2D spectrum is to be corrected by the so-called rho-filter to compensate its 1/f_r amplitude characteristic. Finally the resulting 2D spectrum is Fourier-retransformed and results in the desired image.
>
> Principally you should be able to compute all steps by use of ImageJ and perhaps you will even find an appropriate ImageJ-plugin.
>
> In any case, the FFT must lead to complex-valued spectra. Power spectra make no sense in this application.
>
> Good luck
>
> Herbie
>
> ::::::::::::::::::::::::::::::::::::::::
> On 25.09.14 09:07, Ludovic Pinier wrote:
>> Herbie,
>>
>> the pictures I work with are 16bits unsigned grey level from a CT machine (raw format). No color.
>> And using a Fourier transform is the method described in the standard applying to CT I use (ASTM E-1695). This standard also prevents to remove the mean or alter the contrast/brightness. To be standard-compliant, profile (the "Edge Spread Function") is mandatory. You are only allowed to frequency-filter it, and remove aberrant points. Even the Fourier transform sampling has to be compliant with the standard criteria.
>> Concerning the Fourier transform, I am used to manipulate time-frequency transforms, but not to deal with the programming aspects.
>> Last, my reason is that the tool built in the machine is not accurate.
>> And the "slanted edge method" plugin is inappropriate for the geometry of my targets (which are also defined according to the standard: material, shape and size).
>> The standard requires a line profile, and the slanted edge produces an integration of the profile along the edge.
>> I could use this plugin with 1pixel-wide areas, but ,that means I need to rotate the image; and even if is an as-accurate-as-possible transformation, it is an interpolation that produces a calculated image. It is not the direct capture from the sensor anymore. That is also the reason why the slanted edge method was introduced in the ISO12233. But unfortunately, the target definition in this standard is inappropriate for my use.
>>
>> I know your suggestions could definitely help, but they don't apply to my need.
>>
>> Best regards,
>> Ludovic
>>
>> --
>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>
>
> --
> 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: 1D Fourier transform in macro

Ludovic Pinier
In reply to this post by Ludovic Pinier
Thanks everybody for the help and being so responsive.

Yes Michael, that is exactly what I want.

Thanks to Francis, I got the kick I needed and it works.
I appreciate the trick with the built-in commands.

best regards,
Ludovic

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

Re: 1D Fourier transform in macro

Herbie-4
In reply to this post by Michael Schmid
Thanks Michael,

I really wonder why Ludovic couldn't explain his desire in a sound way.

Yes, of course, ImageJ can do a 1D FFT and in fact what you get in your
test is what is to be expected. There is no need for another FFT-algorithm.

BTW, except for the spectral value at the origin (DC-component) and for
an amplitude scale factor, I get the same result from the FFT of the
single line (PSF) image. Dividing the value at the origin by n should
help with the exaggerated DC when taking the FFT of single line images.

Best

Herbie

::::::::::::::::::::::::::::::::::::::::
On 25.09.14 15:03, Michael Schmid wrote:

> Hi Herbie, Ludovic,
>
> to me it looks like Ludovic wants to do a prodecure as described
> here:
>
> http://www.irss.ca/documents/CODES%20&%20STANDARDS_02-28-08/ASTM%20Standards/PDF/E1695.PDF
>
>  The procedure is essentially determining the one-dimensional point
> spread function (PSF) from the derivative of the image of an edge,
> and then taking the Fourier transform of the PSF to find the
> modulation transfer function (MTF).
>
> So it is really just the Fourier transform of the PSF that is
> needed.
>
> For that purpose, I agree with Ludovic that no background should be
> subtracted.
>
> So I tried creating a line with a PSF-like function, replicated it to
> get a 32-bit square image with a size of 2^n, and ran FFT on it. The
> raw power spectrum does not give a single pixel in the center but
> rather a short streak. Then one can do 'Swap Quadrants', run
> Math>Square Root, select a rectangle of only the first row and do a
> profile. This profile should be the FFT required for converting the
> PSF into the MTF.
>
> So one can do it without doing a 1D FFT.
>
>
> Michael
> ________________________________________________________________ On
> Sep 25, 2014, at 11:14, Herbie wrote:
>
>> Ludovic,
>>
>> I must admit that I'm confused!
>>
>> First you wrote: "This is to perform direct _MTF_ evaluation from
>> the profile"
>>
>> Now you write: "It is for _CT_ (reconstruction)"
>>
>> You also wrote: "What I get is a single _colored_ pixel"
>>
>> Now you write: "16bits unsigned _grey_ level"
>>
>> If you are indeed seeking to reconstruct images from CT projections
>> (not profiles) then there exist several methods to do so. I'm quite
>> familiar with CT but not with formal standards and norms.
>>
>> One way of reconstructing images from projections is by first
>> Fourier-transforming all projections (you need at least n * PI/2
>> projections, where n is the number of pixels of the properly
>> sampled projections). The resulting 1D Fourier-spectra are then
>> combined to give a 2D spectrum by properly rotated superposition of
>> the 1D spectra. This 2D spectrum is to be corrected by the
>> so-called rho-filter to compensate its 1/f_r amplitude
>> characteristic. Finally the resulting 2D spectrum is
>> Fourier-retransformed and results in the desired image.
>>
>> Principally you should be able to compute all steps by use of
>> ImageJ and perhaps you will even find an appropriate
>> ImageJ-plugin.
>>
>> In any case, the FFT must lead to complex-valued spectra. Power
>> spectra make no sense in this application.
>>
>> Good luck
>>
>> Herbie
>>
>> :::::::::::::::::::::::::::::::::::::::: On 25.09.14 09:07, Ludovic
>> Pinier wrote:
>>> Herbie,
>>>
>>> the pictures I work with are 16bits unsigned grey level from a CT
>>> machine (raw format). No color. And using a Fourier transform is
>>> the method described in the standard applying to CT I use (ASTM
>>> E-1695). This standard also prevents to remove the mean or alter
>>> the contrast/brightness. To be standard-compliant, profile (the
>>> "Edge Spread Function") is mandatory. You are only allowed to
>>> frequency-filter it, and remove aberrant points. Even the Fourier
>>> transform sampling has to be compliant with the standard
>>> criteria. Concerning the Fourier transform, I am used to
>>> manipulate time-frequency transforms, but not to deal with the
>>> programming aspects. Last, my reason is that the tool built in
>>> the machine is not accurate. And the "slanted edge method" plugin
>>> is inappropriate for the geometry of my targets (which are also
>>> defined according to the standard: material, shape and size). The
>>> standard requires a line profile, and the slanted edge produces
>>> an integration of the profile along the edge. I could use this
>>> plugin with 1pixel-wide areas, but ,that means I need to rotate
>>> the image; and even if is an as-accurate-as-possible
>>> transformation, it is an interpolation that produces a calculated
>>> image. It is not the direct capture from the sensor anymore. That
>>> is also the reason why the slanted edge method was introduced in
>>> the ISO12233. But unfortunately, the target definition in this
>>> standard is inappropriate for my use.
>>>
>>> I know your suggestions could definitely help, but they don't
>>> apply to my need.
>>>
>>> Best regards, Ludovic
>>>
>>> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>>
>>
>> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
> -- 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: 1D Fourier transform in macro

Francis Burton-3
Hi Herbie,

I am sure your are right in pointing out that there is no *need* for another
FFT algorithm, but when one's data is in the form of an array, derived e.g.
from a z profile using code in the Z_Profiler plugin, it seems rather convoluted
to have to copy those into an image (which you have to manage the creation
and destruction of), use the built-in command(s), and then copy the values out
again into another array.

Is that really what people who want to derive e.g. a power spectrum from
their 1d array data are expected to do?

Francis
________________________________________
From: ImageJ Interest Group [[hidden email]] on behalf of Herbie [[hidden email]]
Sent: 25 September 2014 15:23
To: [hidden email]
Subject: Re: 1D Fourier transform in macro

Thanks Michael,

I really wonder why Ludovic couldn't explain his desire in a sound way.

Yes, of course, ImageJ can do a 1D FFT and in fact what you get in your
test is what is to be expected. There is no need for another FFT-algorithm.

BTW, except for the spectral value at the origin (DC-component) and for
an amplitude scale factor, I get the same result from the FFT of the
single line (PSF) image. Dividing the value at the origin by n should
help with the exaggerated DC when taking the FFT of single line images.

Best

Herbie

::::::::::::::::::::::::::::::::::::::::
On 25.09.14 15:03, Michael Schmid wrote:

> Hi Herbie, Ludovic,
>
> to me it looks like Ludovic wants to do a prodecure as described
> here:
>
> http://www.irss.ca/documents/CODES%20&%20STANDARDS_02-28-08/ASTM%20Standards/PDF/E1695.PDF
>
>  The procedure is essentially determining the one-dimensional point
> spread function (PSF) from the derivative of the image of an edge,
> and then taking the Fourier transform of the PSF to find the
> modulation transfer function (MTF).
>
> So it is really just the Fourier transform of the PSF that is
> needed.
>
> For that purpose, I agree with Ludovic that no background should be
> subtracted.
>
> So I tried creating a line with a PSF-like function, replicated it to
> get a 32-bit square image with a size of 2^n, and ran FFT on it. The
> raw power spectrum does not give a single pixel in the center but
> rather a short streak. Then one can do 'Swap Quadrants', run
> Math>Square Root, select a rectangle of only the first row and do a
> profile. This profile should be the FFT required for converting the
> PSF into the MTF.
>
> So one can do it without doing a 1D FFT.
>
>
> Michael
> ________________________________________________________________ On
> Sep 25, 2014, at 11:14, Herbie wrote:
>
>> Ludovic,
>>
>> I must admit that I'm confused!
>>
>> First you wrote: "This is to perform direct _MTF_ evaluation from
>> the profile"
>>
>> Now you write: "It is for _CT_ (reconstruction)"
>>
>> You also wrote: "What I get is a single _colored_ pixel"
>>
>> Now you write: "16bits unsigned _grey_ level"
>>
>> If you are indeed seeking to reconstruct images from CT projections
>> (not profiles) then there exist several methods to do so. I'm quite
>> familiar with CT but not with formal standards and norms.
>>
>> One way of reconstructing images from projections is by first
>> Fourier-transforming all projections (you need at least n * PI/2
>> projections, where n is the number of pixels of the properly
>> sampled projections). The resulting 1D Fourier-spectra are then
>> combined to give a 2D spectrum by properly rotated superposition of
>> the 1D spectra. This 2D spectrum is to be corrected by the
>> so-called rho-filter to compensate its 1/f_r amplitude
>> characteristic. Finally the resulting 2D spectrum is
>> Fourier-retransformed and results in the desired image.
>>
>> Principally you should be able to compute all steps by use of
>> ImageJ and perhaps you will even find an appropriate
>> ImageJ-plugin.
>>
>> In any case, the FFT must lead to complex-valued spectra. Power
>> spectra make no sense in this application.
>>
>> Good luck
>>
>> Herbie
>>
>> :::::::::::::::::::::::::::::::::::::::: On 25.09.14 09:07, Ludovic
>> Pinier wrote:
>>> Herbie,
>>>
>>> the pictures I work with are 16bits unsigned grey level from a CT
>>> machine (raw format). No color. And using a Fourier transform is
>>> the method described in the standard applying to CT I use (ASTM
>>> E-1695). This standard also prevents to remove the mean or alter
>>> the contrast/brightness. To be standard-compliant, profile (the
>>> "Edge Spread Function") is mandatory. You are only allowed to
>>> frequency-filter it, and remove aberrant points. Even the Fourier
>>> transform sampling has to be compliant with the standard
>>> criteria. Concerning the Fourier transform, I am used to
>>> manipulate time-frequency transforms, but not to deal with the
>>> programming aspects. Last, my reason is that the tool built in
>>> the machine is not accurate. And the "slanted edge method" plugin
>>> is inappropriate for the geometry of my targets (which are also
>>> defined according to the standard: material, shape and size). The
>>> standard requires a line profile, and the slanted edge produces
>>> an integration of the profile along the edge. I could use this
>>> plugin with 1pixel-wide areas, but ,that means I need to rotate
>>> the image; and even if is an as-accurate-as-possible
>>> transformation, it is an interpolation that produces a calculated
>>> image. It is not the direct capture from the sensor anymore. That
>>> is also the reason why the slanted edge method was introduced in
>>> the ISO12233. But unfortunately, the target definition in this
>>> standard is inappropriate for my use.
>>>
>>> I know your suggestions could definitely help, but they don't
>>> apply to my need.
>>>
>>> Best regards, Ludovic
>>>
>>> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>>
>>
>> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>
> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
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: 1D Fourier transform in macro

Herbie-4
Sorry Francis,

but here is the original demand of Ludovic:

"I would like to perform a Fourier transform on a profile, and nest it
in an ImageJ macro.
I already saw that it is quite new (July 2014) that 1D transform is more
easily accessible through FHT.transform1D
I am OK with the macro built-in commands, but not with more
sophisticated things."

What is wrong with recommending built-in IJ features (here: FFT) to
someone who asks for an IJ-macro solution?
It is really easy to generate 1D images from numerical data by use of an
IJ-macro, especially since processing speed appears to be less
important. No "sophisticated things" are involved.

Of course you may write a dedicated IJ-plugin. If Ludovic had asked for
Java FFT code instead, I could have sent him some.

Best regards

Herbie

::::::::::::::::::::::::::::::::::::::::
On 25.09.14 16:45, Francis Burton wrote:

> Hi Herbie,
>
> I am sure your are right in pointing out that there is no *need* for another
> FFT algorithm, but when one's data is in the form of an array, derived e.g.
> from a z profile using code in the Z_Profiler plugin, it seems rather convoluted
> to have to copy those into an image (which you have to manage the creation
> and destruction of), use the built-in command(s), and then copy the values out
> again into another array.
>
> Is that really what people who want to derive e.g. a power spectrum from
> their 1d array data are expected to do?
>
> Francis
> ________________________________________
> From: ImageJ Interest Group [[hidden email]] on behalf of Herbie [[hidden email]]
> Sent: 25 September 2014 15:23
> To: [hidden email]
> Subject: Re: 1D Fourier transform in macro
>
> Thanks Michael,
>
> I really wonder why Ludovic couldn't explain his desire in a sound way.
>
> Yes, of course, ImageJ can do a 1D FFT and in fact what you get in your
> test is what is to be expected. There is no need for another FFT-algorithm.
>
> BTW, except for the spectral value at the origin (DC-component) and for
> an amplitude scale factor, I get the same result from the FFT of the
> single line (PSF) image. Dividing the value at the origin by n should
> help with the exaggerated DC when taking the FFT of single line images.
>
> Best
>
> Herbie
>
> ::::::::::::::::::::::::::::::::::::::::
> On 25.09.14 15:03, Michael Schmid wrote:
>> Hi Herbie, Ludovic,
>>
>> to me it looks like Ludovic wants to do a prodecure as described
>> here:
>>
>> http://www.irss.ca/documents/CODES%20&%20STANDARDS_02-28-08/ASTM%20Standards/PDF/E1695.PDF
>>
>>   The procedure is essentially determining the one-dimensional point
>> spread function (PSF) from the derivative of the image of an edge,
>> and then taking the Fourier transform of the PSF to find the
>> modulation transfer function (MTF).
>>
>> So it is really just the Fourier transform of the PSF that is
>> needed.
>>
>> For that purpose, I agree with Ludovic that no background should be
>> subtracted.
>>
>> So I tried creating a line with a PSF-like function, replicated it to
>> get a 32-bit square image with a size of 2^n, and ran FFT on it. The
>> raw power spectrum does not give a single pixel in the center but
>> rather a short streak. Then one can do 'Swap Quadrants', run
>> Math>Square Root, select a rectangle of only the first row and do a
>> profile. This profile should be the FFT required for converting the
>> PSF into the MTF.
>>
>> So one can do it without doing a 1D FFT.
>>
>>
>> Michael
>> ________________________________________________________________ On
>> Sep 25, 2014, at 11:14, Herbie wrote:
>>
>>> Ludovic,
>>>
>>> I must admit that I'm confused!
>>>
>>> First you wrote: "This is to perform direct _MTF_ evaluation from
>>> the profile"
>>>
>>> Now you write: "It is for _CT_ (reconstruction)"
>>>
>>> You also wrote: "What I get is a single _colored_ pixel"
>>>
>>> Now you write: "16bits unsigned _grey_ level"
>>>
>>> If you are indeed seeking to reconstruct images from CT projections
>>> (not profiles) then there exist several methods to do so. I'm quite
>>> familiar with CT but not with formal standards and norms.
>>>
>>> One way of reconstructing images from projections is by first
>>> Fourier-transforming all projections (you need at least n * PI/2
>>> projections, where n is the number of pixels of the properly
>>> sampled projections). The resulting 1D Fourier-spectra are then
>>> combined to give a 2D spectrum by properly rotated superposition of
>>> the 1D spectra. This 2D spectrum is to be corrected by the
>>> so-called rho-filter to compensate its 1/f_r amplitude
>>> characteristic. Finally the resulting 2D spectrum is
>>> Fourier-retransformed and results in the desired image.
>>>
>>> Principally you should be able to compute all steps by use of
>>> ImageJ and perhaps you will even find an appropriate
>>> ImageJ-plugin.
>>>
>>> In any case, the FFT must lead to complex-valued spectra. Power
>>> spectra make no sense in this application.
>>>
>>> Good luck
>>>
>>> Herbie
>>>
>>> :::::::::::::::::::::::::::::::::::::::: On 25.09.14 09:07, Ludovic
>>> Pinier wrote:
>>>> Herbie,
>>>>
>>>> the pictures I work with are 16bits unsigned grey level from a CT
>>>> machine (raw format). No color. And using a Fourier transform is
>>>> the method described in the standard applying to CT I use (ASTM
>>>> E-1695). This standard also prevents to remove the mean or alter
>>>> the contrast/brightness. To be standard-compliant, profile (the
>>>> "Edge Spread Function") is mandatory. You are only allowed to
>>>> frequency-filter it, and remove aberrant points. Even the Fourier
>>>> transform sampling has to be compliant with the standard
>>>> criteria. Concerning the Fourier transform, I am used to
>>>> manipulate time-frequency transforms, but not to deal with the
>>>> programming aspects. Last, my reason is that the tool built in
>>>> the machine is not accurate. And the "slanted edge method" plugin
>>>> is inappropriate for the geometry of my targets (which are also
>>>> defined according to the standard: material, shape and size). The
>>>> standard requires a line profile, and the slanted edge produces
>>>> an integration of the profile along the edge. I could use this
>>>> plugin with 1pixel-wide areas, but ,that means I need to rotate
>>>> the image; and even if is an as-accurate-as-possible
>>>> transformation, it is an interpolation that produces a calculated
>>>> image. It is not the direct capture from the sensor anymore. That
>>>> is also the reason why the slanted edge method was introduced in
>>>> the ISO12233. But unfortunately, the target definition in this
>>>> standard is inappropriate for my use.
>>>>
>>>> I know your suggestions could definitely help, but they don't
>>>> apply to my need.
>>>>
>>>> Best regards, Ludovic
>>>>
>>>> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>>>
>>>
>>> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>
>> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
> --
> 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: 1D Fourier transform in macro

Ludovic Pinier
In reply to this post by Ludovic Pinier
Hello everybody,

of course I could first have asked for some tricks to get the power spectrum  of a profile, based on ImageJ commands.
Until now, I really never needed any extra function in ImageJ; and I've been using it from the GUI for years now.

I could have added some details from the beginning and explain that I want to follow a strict protocol from standards.
I thought my demand was clear enough, especially when I cited "FHT.transform1D".

Anyway, I may made Herbie misunderstood when I wrote that I don't feel at ease with sophisticated things.
But it is not easy to describe a complete situation in an email that is few lines.
Hopefully, Francis understood my need.

And once again, thanks everyone because you all answered the question, and on top of it: very quickly.
Ludovic

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

Re: 1D Fourier transform in macro

Michael Schmid
Hi Ludovic,

in the latest daily build, Wayne has added an Array.fourier(theArray,
windowType) macro function, based on code snippets that I have sent to
him. Use Help>Update ImageJ to obtain the daily build.

There is some documentation and a text macro for the new function at

http://imagej.nih.gov/ij/macros/examples/TestArrayFourier.txt

In your case, with data values approaching (or equel to) zero at the
beginning and end of the array, you don't need a window function; simply
omit that parameter or write "none" (with the quotes!) for the windowType.

Michael

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

Re: 1D Fourier transform in macro

Herbie-4
Good day Michael and Wayne,

the IJ-macro routine Array.fourier(...) is good news, but why not
optionally output the complex-valued 1D Fourier transform?

One may add a third parameter that, if not present, will result in the
magnitude of the 1D Fourier transform. Otherwise the parameter indicates
that the complex-valued 1D Fourier transform (real & imaginary, or
magnitude & phase) is to be returned.

A possible array format for the transform is discussed in "Numerical
Recipes". It is based on the fact that the first and last imaginary
values are known to be zero and therefore need not be stored in the array.

Just a suggestion...

Best regards

Herbie

::::::::::::::::::::::::::::::::::::::::
On 28.09.14 21:12, Michael Schmid wrote:

> Hi Ludovic,
>
> in the latest daily build, Wayne has added an Array.fourier(theArray,
> windowType) macro function, based on code snippets that I have sent to
> him. Use Help>Update ImageJ to obtain the daily build.
>
> There is some documentation and a text macro for the new function at
>
> http://imagej.nih.gov/ij/macros/examples/TestArrayFourier.txt
>
> In your case, with data values approaching (or equel to) zero at the
> beginning and end of the array, you don't need a window function; simply
> omit that parameter or write "none" (with the quotes!) for the windowType.
>
> Michael
>
> --
> 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: 1D Fourier transform in macro

Ludovic Pinier
Good morning,

Thanks a lot for this news.
I will try this new macro asap.

Best regards,
Ludovic


-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Herbie
Sent: Montag, 29. September 2014 12:30
To: [hidden email]
Subject: Re: 1D Fourier transform in macro

Good day Michael and Wayne,

the IJ-macro routine Array.fourier(...) is good news, but why not optionally output the complex-valued 1D Fourier transform?

One may add a third parameter that, if not present, will result in the magnitude of the 1D Fourier transform. Otherwise the parameter indicates that the complex-valued 1D Fourier transform (real & imaginary, or magnitude & phase) is to be returned.

A possible array format for the transform is discussed in "Numerical Recipes". It is based on the fact that the first and last imaginary values are known to be zero and therefore need not be stored in the array.

Just a suggestion...

Best regards

Herbie

::::::::::::::::::::::::::::::::::::::::
On 28.09.14 21:12, Michael Schmid wrote:

> Hi Ludovic,
>
> in the latest daily build, Wayne has added an Array.fourier(theArray,
> windowType) macro function, based on code snippets that I have sent to
> him. Use Help>Update ImageJ to obtain the daily build.
>
> There is some documentation and a text macro for the new function at
>
> http://imagej.nih.gov/ij/macros/examples/TestArrayFourier.txt
>
> In your case, with data values approaching (or equel to) zero at the
> beginning and end of the array, you don't need a window function;
> simply omit that parameter or write "none" (with the quotes!) for the windowType.
>
> Michael
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

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

________________________________
CONFIDENTIALITY : This e-mail and any attachments are confidential and may be privileged. If you are not a named recipient, please notify the sender immediately and do not disclose the contents to another person, use it for any purpose or store or copy the information in any medium.

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