FFT along line in image

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

FFT along line in image

Jon Harman
Hi,

Is there a plugin to ImageJ that can calculate the FFT along a line in
the image and display the result (say for instance plot the power spectrum)?

Jon
Reply | Threaded
Open this post in threaded view
|

Re: FFT along line in image

Gluender
Dear Jon Harman,

what you are looking for is the 1D Fourier Transformation which has
no direct relation to image processing. Consequently, you may have a
look at general signal rpocessing software. You will find a lot of
free 1D FFT code in the internet. I sometimes use a macro that comes
with Kaleidagraph that in turn can be use in a demo mode for free
(Mac & Windows versions available).

>Hi,
>
>Is there a plugin to ImageJ that can calculate the FFT along a line
>in the image and display the result (say for instance plot the power
>spectrum)?
>
>Jon

I suggest to export the line data etc.

If precision and computational effort is not an issue you may even
apply a 2D FFT to the line (set the rest of the image to zero) and
you will get the Fourier spectrum of this line projected in one
dimension.

HTH
--


                   Herbie

          ------------------------

          <http://www.gluender.de>
Reply | Threaded
Open this post in threaded view
|

Re: FFT along line in image

Frederic V. Hessman
On the contrary, this has everything to do with "image processing":  
there is no reason why "images" have to be 2-D and probably the  
greatest weakness of ImageJ (don't get me wrong - I think it's  
great!) is the inability to assign different scales and meaning to  
different axes of arbritrary dimension.   Yes, there are plugins, but  
this needs to be at the heart of the ImageJ data model.

A sonogram (x=frequency, y=time) is usually displayed as an image.

Rick

On 23 Oct 2007, at 5:10 pm, Gluender wrote:

> Dear Jon Harman,
>
> what you are looking for is the 1D Fourier Transformation which has  
> no direct relation to image processing. Consequently, you may have  
> a look at general signal rpocessing software. You will find a lot  
> of free 1D FFT code in the internet. I sometimes use a macro that  
> comes with Kaleidagraph that in turn can be use in a demo mode for  
> free (Mac & Windows versions available).
>
>> Hi,
>>
>> Is there a plugin to ImageJ that can calculate the FFT along a  
>> line in the image and display the result (say for instance plot  
>> the power spectrum)?
>>
>> Jon
>
> I suggest to export the line data etc.
>
> If precision and computational effort is not an issue you may even  
> apply a 2D FFT to the line (set the rest of the image to zero) and  
> you will get the Fourier spectrum of this line projected in one  
> dimension.



------------------------------------------------------------------------
------------------------
Dr. Frederic V. Hessman     [hidden email]
Institut für Astrophysik          Tel.  +49-551-39-5052
Friedrich-Hund-Platz 1         Fax +49-551-39-5043
37077 Goettingen                 Room F04-133
http://www.Astro.physik.Uni-Goettingen.de/~hessman
------------------------------------------------------------------------
-------------------------
MONET: a MOnitoring NEtwork of Telescopes
http://monet.Uni-Goettingen.de
------------------------------------------------------------------------
-------------------------
Reply | Threaded
Open this post in threaded view
|

Re: FFT along line in image

Jay Unruh
I will echo this sentiment.  It would be straightforward to do these
analyses if the line data were available to a plugin.  Unfortunately, one
has to obtain this data through the List button which reduces the data to
three decimal points precision.

Jay
--
Dr. Jay Unruh
Laboratory for Fluorescence Dynamics, Room 3311
Natural Sciences 2 Building
University of California, Irvine
Irvine, CA 92697
Phone: (949) 266-7405

> On the contrary, this has everything to do with "image processing":
> there is no reason why "images" have to be 2-D and probably the
> greatest weakness of ImageJ (don't get me wrong - I think it's
> great!) is the inability to assign different scales and meaning to
> different axes of arbritrary dimension.   Yes, there are plugins, but
> this needs to be at the heart of the ImageJ data model.
>
> A sonogram (x=frequency, y=time) is usually displayed as an image.
>
> Rick
>
> On 23 Oct 2007, at 5:10 pm, Gluender wrote:
>
>> Dear Jon Harman,
>>
>> what you are looking for is the 1D Fourier Transformation which has
>> no direct relation to image processing. Consequently, you may have
>> a look at general signal rpocessing software. You will find a lot
>> of free 1D FFT code in the internet. I sometimes use a macro that
>> comes with Kaleidagraph that in turn can be use in a demo mode for
>> free (Mac & Windows versions available).
>>
>>> Hi,
>>>
>>> Is there a plugin to ImageJ that can calculate the FFT along a
>>> line in the image and display the result (say for instance plot
>>> the power spectrum)?
>>>
>>> Jon
>>
>> I suggest to export the line data etc.
>>
>> If precision and computational effort is not an issue you may even
>> apply a 2D FFT to the line (set the rest of the image to zero) and
>> you will get the Fourier spectrum of this line projected in one
>> dimension.
>
>
>
> ------------------------------------------------------------------------
> ------------------------
> Dr. Frederic V. Hessman     [hidden email]
> Institut für Astrophysik          Tel.  +49-551-39-5052
> Friedrich-Hund-Platz 1         Fax +49-551-39-5043
> 37077 Goettingen                 Room F04-133
> http://www.Astro.physik.Uni-Goettingen.de/~hessman
> ------------------------------------------------------------------------
> -------------------------
> MONET: a MOnitoring NEtwork of Telescopes
> http://monet.Uni-Goettingen.de
> ------------------------------------------------------------------------
> -------------------------
>
Reply | Threaded
Open this post in threaded view
|

Re: FFT along line in image

Gluender
Dear Jay Unruh,

can't follow you with the precision issue. You
can conveniently access all IJ data with the
appropriate decimal precision by using IJ-macros.
Furthermore, import and export of data to and
from IJ is straightforward.

Best

Herbie

>I will echo this sentiment.  It would be straightforward to do these
>analyses if the line data were available to a plugin.  Unfortunately, one
>has to obtain this data through the List button which reduces the data to
>three decimal points precision.
>
>Jay
>--
>Dr. Jay Unruh
>Laboratory for Fluorescence Dynamics, Room 3311
>Natural Sciences 2 Building
>University of California, Irvine
>Irvine, CA 92697
>Phone: (949) 266-7405
>
>>  On the contrary, this has everything to do with "image processing":
>>  there is no reason why "images" have to be 2-D and probably the
>>  greatest weakness of ImageJ (don't get me wrong - I think it's
>>  great!) is the inability to assign different scales and meaning to
>>  different axes of arbritrary dimension.   Yes, there are plugins, but
>>  this needs to be at the heart of the ImageJ data model.
>>
>>  A sonogram (x=frequency, y=time) is usually displayed as an image.
>>
>>  Rick
>>
>>  On 23 Oct 2007, at 5:10 pm, Gluender wrote:
>>
>>>  Dear Jon Harman,
>>>
>>>  what you are looking for is the 1D Fourier Transformation which has
>>>  no direct relation to image processing. Consequently, you may have
>>>  a look at general signal rpocessing software. You will find a lot
>>>  of free 1D FFT code in the internet. I sometimes use a macro that
>>>  comes with Kaleidagraph that in turn can be use in a demo mode for
>>>  free (Mac & Windows versions available).
>>>
>>>>  Hi,
>>>>
>>>>  Is there a plugin to ImageJ that can calculate the FFT along a
>>>>  line in the image and display the result (say for instance plot
>>>>  the power spectrum)?
>>>>
>>>>  Jon
>>>
>>>  I suggest to export the line data etc.
>>>
>>>  If precision and computational effort is not an issue you may even
>>>  apply a 2D FFT to the line (set the rest of the image to zero) and
>>>  you will get the Fourier spectrum of this line projected in one
>  >> dimension.
>  >
>  > ------------------------------------------------------------------------
>>  ------------------------
>>  Dr. Frederic V. Hessman     [hidden email]
>>  Institut für Astrophysik          Tel.  +49-551-39-5052
>>  Friedrich-Hund-Platz 1         Fax +49-551-39-5043
>>  37077 Goettingen                 Room F04-133
>>  http://www.Astro.physik.Uni-Goettingen.de/~hessman
>>  ------------------------------------------------------------------------
>>  -------------------------
>>  MONET: a MOnitoring NEtwork of Telescopes
>>  http://monet.Uni-Goettingen.de
>>  ------------------------------------------------------------------------
>  > -------------------------
Reply | Threaded
Open this post in threaded view
|

Re: FFT along line in image

Wayne Rasband
In reply to this post by Jay Unruh
A plugin can get the line profile data using

     ProfilePlot pp = new ProfilePlot(imp);
     double[] array = pp.getProfile();

where 'imp' is an ImagePlus with a line selection. Macros can use

     profile = getProfile();

The number of decimal places used by the "List" button (up to 9) can be  
set in the Analyze>Measurement Options dialog box.

-wayne

On Oct 23, 2007, at 12:34 PM, Jay Unruh wrote:

> I will echo this sentiment.  It would be straightforward to do these
> analyses if the line data were available to a plugin.  Unfortunately,  
> one
> has to obtain this data through the List button which reduces the data  
> to
> three decimal points precision.
>
> Jay
> --  
> Dr. Jay Unruh
> Laboratory for Fluorescence Dynamics, Room 3311
> Natural Sciences 2 Building
> University of California, Irvine
> Irvine, CA 92697
> Phone: (949) 266-7405
>
>> On the contrary, this has everything to do with "image processing":
>> there is no reason why "images" have to be 2-D and probably the
>> greatest weakness of ImageJ (don't get me wrong - I think it's
>> great!) is the inability to assign different scales and meaning to
>> different axes of arbritrary dimension.   Yes, there are plugins, but
>> this needs to be at the heart of the ImageJ data model.
>>
>> A sonogram (x=frequency, y=time) is usually displayed as an image.
>>
>> Rick
>>
>> On 23 Oct 2007, at 5:10 pm, Gluender wrote:
>>
>>> Dear Jon Harman,
>>>
>>> what you are looking for is the 1D Fourier Transformation which has
>>> no direct relation to image processing. Consequently, you may have
>>> a look at general signal rpocessing software. You will find a lot
>>> of free 1D FFT code in the internet. I sometimes use a macro that
>>> comes with Kaleidagraph that in turn can be use in a demo mode for
>>> free (Mac & Windows versions available).
>>>
>>>> Hi,
>>>>
>>>> Is there a plugin to ImageJ that can calculate the FFT along a
>>>> line in the image and display the result (say for instance plot
>>>> the power spectrum)?
>>>>
>>>> Jon
>>>
>>> I suggest to export the line data etc.
>>>
>>> If precision and computational effort is not an issue you may even
>>> apply a 2D FFT to the line (set the rest of the image to zero) and
>>> you will get the Fourier spectrum of this line projected in one
>>> dimension.
>>
>>
>>
>> ----------------------------------------------------------------------
>> --
>> ------------------------
>> Dr. Frederic V. Hessman     [hidden email]
>> Institut für Astrophysik          Tel.  +49-551-39-5052
>> Friedrich-Hund-Platz 1         Fax +49-551-39-5043
>> 37077 Goettingen                 Room F04-133
>> http://www.Astro.physik.Uni-Goettingen.de/~hessman
>> ----------------------------------------------------------------------
>> --
>> -------------------------
>> MONET: a MOnitoring NEtwork of Telescopes
>> http://monet.Uni-Goettingen.de
>> ----------------------------------------------------------------------
>> --
>> -------------------------
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: FFT along line in image

Jay Unruh
This is only valid if the profile plot was created earlier in the same
plugin.  Once the creating plugin has terminated the data is only
accessible via the list or copy buttons, right?  The same is true for
the axes scales, etc.

Thanks for the info about measurement options.

Jay

Wayne Rasband wrote:

> A plugin can get the line profile data using
>
>     ProfilePlot pp = new ProfilePlot(imp);
>     double[] array = pp.getProfile();
>
> where 'imp' is an ImagePlus with a line selection. Macros can use
>
>     profile = getProfile();
>
> The number of decimal places used by the "List" button (up to 9) can
> be set in the Analyze>Measurement Options dialog box.
>
> -wayne
>
> On Oct 23, 2007, at 12:34 PM, Jay Unruh wrote:
>
>> I will echo this sentiment.  It would be straightforward to do these
>> analyses if the line data were available to a plugin.  Unfortunately,
>> one
>> has to obtain this data through the List button which reduces the
>> data to
>> three decimal points precision.
>>
>> Jay
>> -- Dr. Jay Unruh
>> Laboratory for Fluorescence Dynamics, Room 3311
>> Natural Sciences 2 Building
>> University of California, Irvine
>> Irvine, CA 92697
>> Phone: (949) 266-7405
>>
>>> On the contrary, this has everything to do with "image processing":
>>> there is no reason why "images" have to be 2-D and probably the
>>> greatest weakness of ImageJ (don't get me wrong - I think it's
>>> great!) is the inability to assign different scales and meaning to
>>> different axes of arbritrary dimension.   Yes, there are plugins, but
>>> this needs to be at the heart of the ImageJ data model.
>>>
>>> A sonogram (x=frequency, y=time) is usually displayed as an image.
>>>
>>> Rick
>>>
>>> On 23 Oct 2007, at 5:10 pm, Gluender wrote:
>>>
>>>> Dear Jon Harman,
>>>>
>>>> what you are looking for is the 1D Fourier Transformation which has
>>>> no direct relation to image processing. Consequently, you may have
>>>> a look at general signal rpocessing software. You will find a lot
>>>> of free 1D FFT code in the internet. I sometimes use a macro that
>>>> comes with Kaleidagraph that in turn can be use in a demo mode for
>>>> free (Mac & Windows versions available).
>>>>
>>>>> Hi,
>>>>>
>>>>> Is there a plugin to ImageJ that can calculate the FFT along a
>>>>> line in the image and display the result (say for instance plot
>>>>> the power spectrum)?
>>>>>
>>>>> Jon
>>>>
>>>> I suggest to export the line data etc.
>>>>
>>>> If precision and computational effort is not an issue you may even
>>>> apply a 2D FFT to the line (set the rest of the image to zero) and
>>>> you will get the Fourier spectrum of this line projected in one
>>>> dimension.
>>>
>>>
>>>
>>> ------------------------------------------------------------------------
>>>
>>> ------------------------
>>> Dr. Frederic V. Hessman     [hidden email]
>>> Institut für Astrophysik          Tel.  +49-551-39-5052
>>> Friedrich-Hund-Platz 1         Fax +49-551-39-5043
>>> 37077 Goettingen                 Room F04-133
>>> http://www.Astro.physik.Uni-Goettingen.de/~hessman
>>> ------------------------------------------------------------------------
>>>
>>> -------------------------
>>> MONET: a MOnitoring NEtwork of Telescopes
>>> http://monet.Uni-Goettingen.de
>>> ------------------------------------------------------------------------
>>>
>>> -------------------------
>>>
>>
Reply | Threaded
Open this post in threaded view
|

Re: FFT along line in image

Gabriel Landini
On Tuesday 23 October 2007, Jay Unruh wrote:
> This is only valid if the profile plot was created earlier in the same
> plugin.  Once the creating plugin has terminated the data is only
> accessible via the list or copy buttons, right?

The profile would be extracted from the selection which is sill on the image,
I think.

G.
Reply | Threaded
Open this post in threaded view
|

Re: FFT along line in image

Adrian Daerr
In reply to this post by Gluender
Herbie Gluender wrote:
> can't follow you with the precision issue. You can conveniently access
> all IJ data with the appropriate decimal precision by using IJ-macros.
> Furthermore, import and export of data to and from IJ is straightforward.

Well, if done naively, export of IJ data can be very treacherous. For
example, if you run the following macro:

newImage("Untitled", "32-bit Ramp", 400, 400, 1);
run("Divide...", "value=100");
makeLine(0, 100, 105, 100);
run("Plot Profile");

you get the plot
http://www.msc.univ-paris-diderot.fr/~daerr/tmp/profileIJ.png

The surprise comes when you save the data to a file (using the Profile
Plot window's "save" button), and plot the data contained in that file
with your favorite program. Here is what you get:
http://www.msc.univ-paris-diderot.fr/~daerr/tmp/profile.png

There is no reason for this, we have never seen a list in the process!
The rounding behaviour might be a good idea for the list window itself
to present data in a more easily readable format, but it leads to very
annoying surprises when saving. Who wants to save rounded data? Very few
people, very rarely, I suspect. If you bother saving a list, it is not
for printing, it is for post-treatment and data analysis most of the
time, and the corresponding programs don't care reading full precision data.
Whatever the rationale behind this, I consider it a bug, I have had the
bug-report on my TODO-list for a while. Here it is then  :-)

Suggested bug-fix: apply rounding only to the list window. When saving,
revert to full precision.

best regards,
Adrian

-- http://www.msc.univ-paris-diderot.fr/~daerr/
Reply | Threaded
Open this post in threaded view
|

Re: FFT along line in image

seb-7
In reply to this post by Jon Harman
Jon Harman wrote:

> Hi,
>
> Is there a plugin to ImageJ that can calculate the FFT along a line in
> the image and display the result (say for instance plot the power
> spectrum)?
>
> Jon
>
> .
>


Hi Jon,

Just for fun,
here is an infamous SlowFT macro, not even well tested.
A better idea would be to use an external FFT lib, like
jnt.fft or others you could use for 1D transform.
http://math.nist.gov/~BMiller/java/
http://www.google.com/codesearch?hl=en&lr=&q=fft+lang%3Ajava+&btnG=Search

and last but not least
http://rsb.info.nih.gov/ij/developer/source/ij/process/FHT.java.html
:-)

seb



SlowFT.txt
-----------------------------------------------------
//"Brute Force" Fourier Transform
//very naive implementation of usual DFTs
//the slowest DFT you can find
//neither symmetry/parity/memoize nor "butterfly" trick
//just raw and slow Discrete Fourier Transform
//unusable with large arrays!

//actually, large is quite small :-)
//direct+inverse transform took 13 sec for 800 pixels
//on a (old) Pentium4 1.6Ghz

var PI=3.1415926536;


macro "LineFTTest"
{
    if (selectionType != 5)
       exit("Line selection required!");

    x=getProfile();
    n=x.length;
    setBatchMode(true);
    T0=getTime();
    F=slowRFT1D(x);
    ift=slowIFT1D(F);
    T1=getTime();
    setBatchMode(false);
    name = "[SlowFT]";
    run("New... ", "name="+name+" type=Table");
    f = name;
 
print(f,"\\Headings:x\tReF=Re(FT(x))\tImF=Im(FT(x))\tRe(IFT(F))\tIm(IFT(F)");
    for(i=0;i<n;i++)
    {
       print(f,x[i]+"\t"+F[i]+"\t"+F[n+i]+"\t"+ift[i]+"\t"+ift[i+n]);
    }
    print("direct and inverse transform of "+n+" values took "+(T1-T0)+
"ms");
}
       I


//direct real FT
function slowRFT1D(real_in)
{
    N=real_in.length;
    S=newArray(2*N);

    for (m=0;m<N;m++)
    {

       RSm=0;
       ISm=0;
       for (k=0;k<N;k++)
       {
          RSm+=real_in[k]*cos(2*PI*k*m/N);
          ISm-=real_in[k]*sin(2*PI*k*m/N);
       }
       S[m]=RSm; //real part
       S[N+m]=ISm; //imaginary part
    }
    return S;
    //S:Complex: {Re[0],..Re[N-1],Im[0]..Im[N-1]}
}

//direct complex FT

function slowFT1D(z_in)
{//z_in complex: {Re[0]..Re[N-1],Im[0]..Im[N-1]}
    N=z_in.length/2;
    S=newArray(2*N);
    for(m=0;m<N;m++)
    {
       RSm=0;
       ISm=0;
       for (k=0;k<N;k++)
       {
          c=cos(2*PI*k*m/N);
          s=-sin(2*PI*k*m/N);
          RSm+=(z_in[k]*c-s*z_in[k+N]);
          ISm+=(z_in[k]*s+c*z_in[k+N]);
       }
       S[m]=RSm;
       S[m+N]=ISm;
    }
    return S;
    // output= complex (as z_in...)
}
//Inverse complex FT
function slowIFT1D(S_in)
{ //S_in complex: {Re[0]..Re[N-1],Im[0]..Im[N-1]}
    N=S_in.length/2;
    sout=newArray(2*N);
    for (k=0;k<N;k++)
    {
       Rsk=0;
       Isk=0;
       for (m=0;m<N;m++)
       {
          c=cos(2*PI*k*m/N);
          s=sin(2*PI*k*m/N);
          Rsk += (S_in[m]*c-s*S_in[m+N]);
          Isk += (S_in[m]*s+c*S_in[m+N]);
       }
       sout[k] = Rsk/N;
       sout[N+k] = Isk/N;
    }
    return sout;
}
Reply | Threaded
Open this post in threaded view
|

Re: FFT along line in image

Burger Wilhelm
In reply to this post by Jon Harman
Jon,

you find a straightforward Java/ImageJ implementation of the one-dimensional DFT (for vectors of arbitrary length, ie., no FFT) in the source code section of our site (http://www.imagingbook.com/index.php?id=98 , Chap. 13). There is also a 2D implementation (Chap. 14) and plugin examples.

Hope this is of any help.

Wilhelm





> -----Original Message-----
> From: ImageJ Interest Group [mailto:[hidden email]] On
> Behalf Of seb
> Sent: Wednesday, October 24, 2007 11:10 PM
> To: [hidden email]
> Subject: Re: FFT along line in image
>
> Jon Harman wrote:
> > Hi,
> >
> > Is there a plugin to ImageJ that can calculate the FFT
> along a line in
> > the image and display the result (say for instance plot the power
> > spectrum)?
> >
> > Jon
> >
> > .
> >
>
>
> Hi Jon,
>
> Just for fun,
> here is an infamous SlowFT macro, not even well tested.
> A better idea would be to use an external FFT lib, like
> jnt.fft or others you could use for 1D transform.
> http://math.nist.gov/~BMiller/java/
> http://www.google.com/codesearch?hl=en&lr=&q=fft+lang%3Ajava+&
> btnG=Search
>
> and last but not least
> http://rsb.info.nih.gov/ij/developer/source/ij/process/FHT.java.html
> :-)
>
> seb
>
>
>
> SlowFT.txt
> -----------------------------------------------------
> //"Brute Force" Fourier Transform
> //very naive implementation of usual DFTs
> //the slowest DFT you can find
> //neither symmetry/parity/memoize nor "butterfly" trick
> //just raw and slow Discrete Fourier Transform
> //unusable with large arrays!
>
> //actually, large is quite small :-)
> //direct+inverse transform took 13 sec for 800 pixels
> //on a (old) Pentium4 1.6Ghz
>
> var PI=3.1415926536;
>
>
> macro "LineFTTest"
> {
>     if (selectionType != 5)
>        exit("Line selection required!");
>
>     x=getProfile();
>     n=x.length;
>     setBatchMode(true);
>     T0=getTime();
>     F=slowRFT1D(x);
>     ift=slowIFT1D(F);
>     T1=getTime();
>     setBatchMode(false);
>     name = "[SlowFT]";
>     run("New... ", "name="+name+" type=Table");
>     f = name;
>  
> print(f,"\\Headings:x\tReF=Re(FT(x))\tImF=Im(FT(x))\tRe(IFT(F)
> )\tIm(IFT(F)");
>     for(i=0;i<n;i++)
>     {
>        print(f,x[i]+"\t"+F[i]+"\t"+F[n+i]+"\t"+ift[i]+"\t"+ift[i+n]);
>     }
>     print("direct and inverse transform of "+n+" values took
> "+(T1-T0)+
> "ms");
> }
>        I
>
>
> //direct real FT
> function slowRFT1D(real_in)
> {
>     N=real_in.length;
>     S=newArray(2*N);
>
>     for (m=0;m<N;m++)
>     {
>
>        RSm=0;
>        ISm=0;
>        for (k=0;k<N;k++)
>        {
>           RSm+=real_in[k]*cos(2*PI*k*m/N);
>           ISm-=real_in[k]*sin(2*PI*k*m/N);
>        }
>        S[m]=RSm; //real part
>        S[N+m]=ISm; //imaginary part
>     }
>     return S;
>     //S:Complex: {Re[0],..Re[N-1],Im[0]..Im[N-1]}
> }
>
> //direct complex FT
>
> function slowFT1D(z_in)
> {//z_in complex: {Re[0]..Re[N-1],Im[0]..Im[N-1]}
>     N=z_in.length/2;
>     S=newArray(2*N);
>     for(m=0;m<N;m++)
>     {
>        RSm=0;
>        ISm=0;
>        for (k=0;k<N;k++)
>        {
>           c=cos(2*PI*k*m/N);
>           s=-sin(2*PI*k*m/N);
>           RSm+=(z_in[k]*c-s*z_in[k+N]);
>           ISm+=(z_in[k]*s+c*z_in[k+N]);
>        }
>        S[m]=RSm;
>        S[m+N]=ISm;
>     }
>     return S;
>     // output= complex (as z_in...)
> }
> //Inverse complex FT
> function slowIFT1D(S_in)
> { //S_in complex: {Re[0]..Re[N-1],Im[0]..Im[N-1]}
>     N=S_in.length/2;
>     sout=newArray(2*N);
>     for (k=0;k<N;k++)
>     {
>        Rsk=0;
>        Isk=0;
>        for (m=0;m<N;m++)
>        {
>           c=cos(2*PI*k*m/N);
>           s=sin(2*PI*k*m/N);
>           Rsk += (S_in[m]*c-s*S_in[m+N]);
>           Isk += (S_in[m]*s+c*S_in[m+N]);
>        }
>        sout[k] = Rsk/N;
>        sout[N+k] = Isk/N;
>     }
>     return sout;
> }
>
Reply | Threaded
Open this post in threaded view
|

Re: FFT along line in image

Jon Harman
In reply to this post by seb-7
Hi,

Maybe there is enough interest to request an addition to the ImageJ fft
routines?

Jon

seb wrote:

> Jon Harman wrote:
>> Hi,
>>
>> Is there a plugin to ImageJ that can calculate the FFT along a line
>> in the image and display the result (say for instance plot the power
>> spectrum)?
>>
>> Jon
>>
>> .
>>
>
>
> Hi Jon,
>
> Just for fun,
> here is an infamous SlowFT macro, not even well tested.
> A better idea would be to use an external FFT lib, like
> jnt.fft or others you could use for 1D transform.
> http://math.nist.gov/~BMiller/java/
> http://www.google.com/codesearch?hl=en&lr=&q=fft+lang%3Ajava+&btnG=Search
>
> and last but not least
> http://rsb.info.nih.gov/ij/developer/source/ij/process/FHT.java.html
> :-)
>
> seb
>
>
>
> SlowFT.txt
> -----------------------------------------------------
> //"Brute Force" Fourier Transform
> //very naive implementation of usual DFTs
> //the slowest DFT you can find
> //neither symmetry/parity/memoize nor "butterfly" trick
> //just raw and slow Discrete Fourier Transform
> //unusable with large arrays!
>
> //actually, large is quite small :-)
> //direct+inverse transform took 13 sec for 800 pixels
> //on a (old) Pentium4 1.6Ghz
>
> var PI=3.1415926536;
>
>
> macro "LineFTTest"
> {
>    if (selectionType != 5)
>       exit("Line selection required!");
>
>    x=getProfile();
>    n=x.length;
>    setBatchMode(true);
>    T0=getTime();
>    F=slowRFT1D(x);
>    ift=slowIFT1D(F);
>    T1=getTime();
>    setBatchMode(false);
>    name = "[SlowFT]";
>    run("New... ", "name="+name+" type=Table");
>    f = name;
>
> print(f,"\\Headings:x\tReF=Re(FT(x))\tImF=Im(FT(x))\tRe(IFT(F))\tIm(IFT(F)");
>
>    for(i=0;i<n;i++)
>    {
>       print(f,x[i]+"\t"+F[i]+"\t"+F[n+i]+"\t"+ift[i]+"\t"+ift[i+n]);
>    }
>    print("direct and inverse transform of "+n+" values took "+(T1-T0)+
> "ms");
> }
>       I
>
>
> //direct real FT
> function slowRFT1D(real_in)
> {
>    N=real_in.length;
>    S=newArray(2*N);
>
>    for (m=0;m<N;m++)
>    {
>
>       RSm=0;
>       ISm=0;
>       for (k=0;k<N;k++)
>       {
>          RSm+=real_in[k]*cos(2*PI*k*m/N);
>          ISm-=real_in[k]*sin(2*PI*k*m/N);
>       }
>       S[m]=RSm; //real part
>       S[N+m]=ISm; //imaginary part
>    }
>    return S;
>    //S:Complex: {Re[0],..Re[N-1],Im[0]..Im[N-1]}
> }
>
> //direct complex FT
>
> function slowFT1D(z_in)
> {//z_in complex: {Re[0]..Re[N-1],Im[0]..Im[N-1]}
>    N=z_in.length/2;
>    S=newArray(2*N);
>    for(m=0;m<N;m++)
>    {
>       RSm=0;
>       ISm=0;
>       for (k=0;k<N;k++)
>       {
>          c=cos(2*PI*k*m/N);
>          s=-sin(2*PI*k*m/N);
>          RSm+=(z_in[k]*c-s*z_in[k+N]);
>          ISm+=(z_in[k]*s+c*z_in[k+N]);
>       }
>       S[m]=RSm;
>       S[m+N]=ISm;
>    }
>    return S;
>    // output= complex (as z_in...)
> }
> //Inverse complex FT
> function slowIFT1D(S_in)
> { //S_in complex: {Re[0]..Re[N-1],Im[0]..Im[N-1]}
>    N=S_in.length/2;
>    sout=newArray(2*N);
>    for (k=0;k<N;k++)
>    {
>       Rsk=0;
>       Isk=0;
>       for (m=0;m<N;m++)
>       {
>          c=cos(2*PI*k*m/N);
>          s=sin(2*PI*k*m/N);
>          Rsk += (S_in[m]*c-s*S_in[m+N]);
>          Isk += (S_in[m]*s+c*S_in[m+N]);
>       }
>       sout[k] = Rsk/N;
>       sout[N+k] = Isk/N;
>    }
>    return sout;
> }
>
Reply | Threaded
Open this post in threaded view
|

OT - Using film or flatbed scanners for microscope slide scanning

Nicholas Verge
Off-topic, but thought the Image-J community might be able to help.

I am considering purchasing of either a high-resolution medium format film  
scanner (~4000dpi hardware optical res) or a high-resolution flatbed  
scanner (>4000dpi hardware optical res)for scanning microscope slides -  
rock thinsections to be precise. Some results of using such kit and which  
have prompted my interest in using scanners, rather than a microscope  
mounted camera, can be seen here:

http://www.microscopy-uk.org.uk/mag/indexmag.html?http://www.microscopy-uk.org.uk/mag/artaug04/dwslidescan.html

Does anyone have any experience of using such scanners for this purpose  
that they would be willing to pass on?

For my purposes i dont need magnifaction beyond the equivalent of a that  
provided by a x10 microscope objective as the mineral grains in my rocks  
samples are quite coarse.  I need to obtain nice evenly illuminated sharp  
images of the entire thinsection if possible.

On the above website, the results are shown of using a 35mm film scanner  
2900dpi and although he has obtained good results for a thinsection, the  
problem with using such a setup is that the orientation of the slid is  
fixed. I wish to use plane polarised light with and without crossed  
polars, so need to be able to place the slide in an arbitary orientation  
relative to the polarisation axes, hence my idea is to use a medium format  
film scanner or flatbed scanner with transparency tray either will give  
more freedom.

Dedicated film scanners being considered for this purpose are Nikon  
Supercoolscan 8000ED/9000ED, Microtek 120tf, Polaroid Sprintscan 120. all  
4000dpi.

Flatbed scanner with transparency tray: Microtek Artixscan F1 (or M1 due  
out next summer) 4800dpi supposedly

Thanks all, for your help.



--
----------------------------------------------------------------------
Nicholas J. Verge BSc. FGS
Henley-on-Thames, Oxfordshire, UK

Geologist
Reply | Threaded
Open this post in threaded view
|

Re: OT - Using film or flatbed scanners for microscope slide scanning

Gabriel Landini
On Thursday 25 October 2007, Nicholas Verge wrote:
> For my purposes i dont need magnifaction beyond the equivalent of a that
> provided by a x10 microscope objective as the mineral grains in my rocks
> samples are quite coarse.  I need to obtain nice evenly illuminated sharp
> images of the entire thinsection if possible.

I have no idea of costs, but the advantage of a microscope is that you can
change magnifications on the fly, add filters, use different cameras, and
illumination settings.
If you never used a scanner before, be aware that you may be disappointed by
the lack of visual feedback between inserting a slide and seeing what has
been scanned. You will not be able to do lapse imaging nor do average capture
to reduce random noise.

Before buying make sure that you have a demo to avoid disappointments.
Cheers,

G.
Reply | Threaded
Open this post in threaded view
|

Re: OT - Using film or flatbed scanners for microscope slide scanning

Jim Quinn-2
In reply to this post by Nicholas Verge
Gabriel and Folks

A good scanner, such as an Epson V700,
will give you surprisingly great results
from about 1x to 30x.  You can scan far
greater areas than can be viewed under
the typical stereoscope.  I routinely
collect 50MByte images, with full control
over brightness, contrast, gamma, colours, etc....

Try collecting a 2"x2" area at 2400 dpi
on a StereoZoom4 at 30X.  It is a snap on
a V700 (and other scanners).  The image is
about 65MByte.  Then try 4"x4" or 8"x10".
No camera has that many equivalent megapixels.

The only down side is the very limited
control of the lighting direction.

regards,

JQuinn

PS: This thread is better off on the MSA listserver,
    the Yahoo group on Microscopy, or the Usenet
    group on Microscopy.

 > From [hidden email]  Thu Oct 25 17:32:26 2007
 > Message-ID:  <[hidden email]>
 > Date:         Thu, 25 Oct 2007 22:35:20 +0100
 > Reply-To: ImageJ Interest Group <[hidden email]>
 > Sender: ImageJ Interest Group <[hidden email]>
 > From: Gabriel Landini <[hidden email]>
 > Organization: The University of Birmingham, UK.
 > Subject: Re: OT - Using film or flatbed scanners for microscope slide scanning
 > To: [hidden email]
 > In-Reply-To:  <[hidden email]>
 > Precedence: list
 >
 > On Thursday 25 October 2007, Nicholas Verge wrote:
 > > For my purposes i dont need magnifaction beyond the equivalent of a that
 > > provided by a x10 microscope objective as the mineral grains in my rocks
 > > samples are quite coarse.  I need to obtain nice evenly illuminated sharp
 > > images of the entire thinsection if possible.
 >
 > I have no idea of costs, but the advantage of a microscope is that you can
 > change magnifications on the fly, add filters, use different cameras, and
 > illumination settings.
 > If you never used a scanner before, be aware that you may be disappointed by
 > the lack of visual feedback between inserting a slide and seeing what has
 > been scanned. You will not be able to do lapse imaging nor do average capture
 > to reduce random noise.
 >
 > Before buying make sure that you have a demo to avoid disappointments.
 > Cheers,
 >
 > G.
 >
Reply | Threaded
Open this post in threaded view
|

Re: OT - Using film or flatbed scanners for microscope slide scanning

your name Charles Lessman
I too can give a testimonial to the value of flatbed scanners in imaging large arrays (in my case zebrafish embryos or oocytes). We use transparency adapters to image time lapse sequences of live embryos and oocytes (for those interested see the refs below). Most recently we have used UMAX Astra 6700 (cost ~$100 !!!) to produce 1200dpi images that are then stacked and analyzed with ImageJ. The scanners are particularly good for getting an overview of many simultaneous treatments and may be automated with macros to scan & archive files unattended. My 2 cents.

39) Lessman, C.A. (2002) Use of computer-aided screening (CAS) for detection of motility mutants in zebrafish embryos. Real-Time Imaging  8:189-201.

41) Lessman, C.A. (2004) Computer-Aided Screening for Zebrafish Embryonic Motility Mutants. Methods in Cell Biology. 76:285-313.

42) Lessman, C. A., Nathani, R.,  Uddin, R., Walker, J. and Liu, J. (2007). Computer-aided meiotic maturation assay (CAMMA) of zebrafish (Danio rerio) oocytes in vitro. Molecular Reproduction and Development 74:99-109. http://dx.doi.org/10.1002/mrd.20530


Charles A. Lessman, Ph.D.
Professor
Dept. of Biology
The University of Memphis
Memphis, TN 38152
(901) 678-2963
FAX (901) 678-4457
http://biology.memphis.edu/clessman.htm
http://umpeople.memphis.edu/clessman

-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Jim Quinn
Sent: Friday, October 26, 2007 9:25 AM
To: [hidden email]
Subject: Re: OT - Using film or flatbed scanners for microscope slide scanning

Gabriel and Folks

A good scanner, such as an Epson V700,
will give you surprisingly great results
from about 1x to 30x.  You can scan far
greater areas than can be viewed under
the typical stereoscope.  I routinely
collect 50MByte images, with full control
over brightness, contrast, gamma, colours, etc....

Try collecting a 2"x2" area at 2400 dpi
on a StereoZoom4 at 30X.  It is a snap on
a V700 (and other scanners).  The image is
about 65MByte.  Then try 4"x4" or 8"x10".
No camera has that many equivalent megapixels.

The only down side is the very limited
control of the lighting direction.

regards,

JQuinn

PS: This thread is better off on the MSA listserver,
    the Yahoo group on Microscopy, or the Usenet
    group on Microscopy.

 > From [hidden email]  Thu Oct 25 17:32:26 2007
 > Message-ID:  <[hidden email]>
 > Date:         Thu, 25 Oct 2007 22:35:20 +0100
 > Reply-To: ImageJ Interest Group <[hidden email]>
 > Sender: ImageJ Interest Group <[hidden email]>
 > From: Gabriel Landini <[hidden email]>
 > Organization: The University of Birmingham, UK.
 > Subject: Re: OT - Using film or flatbed scanners for microscope slide scanning
 > To: [hidden email]
 > In-Reply-To:  <[hidden email]>
 > Precedence: list
 >
 > On Thursday 25 October 2007, Nicholas Verge wrote:
 > > For my purposes i dont need magnifaction beyond the equivalent of a that
 > > provided by a x10 microscope objective as the mineral grains in my rocks
 > > samples are quite coarse.  I need to obtain nice evenly illuminated sharp
 > > images of the entire thinsection if possible.
 >
 > I have no idea of costs, but the advantage of a microscope is that you can
 > change magnifications on the fly, add filters, use different cameras, and
 > illumination settings.
 > If you never used a scanner before, be aware that you may be disappointed by
 > the lack of visual feedback between inserting a slide and seeing what has
 > been scanned. You will not be able to do lapse imaging nor do average capture
 > to reduce random noise.
 >
 > Before buying make sure that you have a demo to avoid disappointments.
 > Cheers,
 >
 > G.
 >