Competition "ImageJ Video Tutorials"

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

Competition "ImageJ Video Tutorials"

Andreas Jahnen
Dear ImageJ Community,

To promote the ImageJ Conference and the ImageJ Documentation Wiki, the
conference organisers arrange a competition. Subjects are video tutorials
for ImageJ. Please check out the homepage for the complete announcement,
including rules and conditions:

http://imagejconf.tudor.lu/competition/

The main facts in short:

- Duration: 01.10.2008 - 01.11.2008
- Videos will be accessible form the ImageJ Documentation Wiki (
http://imagejdocu.tudor.lu)
- The best videos are shown and awarded during the ImageJ User and
Developer Conference
- Attendance on the conference is not obligatory.

Prices
1. Price: Zeiss Primo Star Upright Microscope (value 1200 €) sponsored by
Carl Zeiss, France
2. Price: Book: A Practical Approach to medical image processing by
Elizabeth Berry (value 70 €),
3. Price: Book: Digital Image Processing: An Algorithmic Introduction
using Java by Wilhelm Burger and Mark James Burge (value 60 €)

I hope we will receive a lot of nice video tutorials!

Best Regards,

        Andreas Jahnen

-----------------------------------------------------------------
ImageJ User and Developer Conference 2008
6-7. November 2008
http://imagejconf.tudor.lu
-----------------------------------------------------------------
Andreas Jahnen  -  Ingenieur de Recherche
[hidden email]
-----------------------------------------------------------------
CRP Henri Tudor  -  http://santec.tudor.lu
2A, rue Kalchesbrück
L-1852 Luxembourg
-----------------------------------------------------------------
Reply | Threaded
Open this post in threaded view
|

FFT of sinusoidal grating

Gabriele Umbriaco
Good day to all.
If I compute the FFT with ImageJ the result is not the same of IDL.
I do not understand because, it is wrong ?
You can help me?
Thanks you.
Gabriele

ORIGINAL IMAGE 512x512 http://www.zshare.net/image/19808361cf9f18a5/
IDL FFT 512x512 http://www.zshare.net/image/198083993bc66e61/
IMAGEJ FFT 512x512 http://www.zshare.net/image/1980841949a36387/

ORIGINAL IMAGE 800x800 http://www.zshare.net/image/1980603911fc4e4d/
IDL FFT 800x800 http://www.zshare.net/image/198059600f47c99d/
IMAGEJ FFT 800x800  http://www.zshare.net/image/198060136c636fcb/


>
> IDL code:
>
> ; IDL Version 5.2 (Win32 x86)
> ; Journal File for rockford@C3B0E6
> ; Working directory: D:\RSI\IDL52
> ; Date: Sat Jan 17 18:09:01 2004
> cd, 'C:\immagini'
> read_jpeg,'sin_grid_30.jpg',ima
> image=fltarr(512,512)
> image(*,*)=ima(1:512,1:512)
> dimx=512
> dimy=512
> window, 1, xs=dimx, ys=dimy, title='original'
> tvscl,image
>
> ;Power Spectrum F(u)*F^(u)
> window, 2, xs=dimx, ys=dimy, title='Filtered Power Spectrum'
> pspect= shift((fft(image, -1)*fft(conj(image),1)),dimx/2,dimy/2)
> tvscl, pspect
>
> write_jpeg, 'FFT_IDL.jpg', pspect, Quality=100
> write_jpeg, 'sin_grid.jpg', image, Quality=100
>
> end
=================================================
Gabriele Umbriaco
Reply | Threaded
Open this post in threaded view
|

Re: FFT of sinusoidal grating

Stefan Heim
Hi Gabriele,

On Thu, 2008-10-02 at 11:45 +0200, Gabriele Umbriaco wrote:
> If I compute the FFT with ImageJ the result is not the same of IDL.
> I do not understand because, it is wrong ?
> You can help me?

General advise: it takes a lot of caution and double-checking to compare
FFT results from two distinct FFT implementations.

> > IDL code:
> >
> > ; IDL Version 5.2 (Win32 x86)
> > ; Journal File for rockford@C3B0E6
> > ; Working directory: D:\RSI\IDL52
> > ; Date: Sat Jan 17 18:09:01 2004
> > cd, 'C:\immagini'
> > read_jpeg,'sin_grid_30.jpg',ima
> > image=fltarr(512,512)
> > image(*,*)=ima(1:512,1:512)

This looks suspicious. sin_grid_30.jpg is a periodic 800x800 pixel
image, and you pick a 512x512 subimage, (accidentally?) offset by 1x1
pixel (array indices in IDL are zero-based!). You don't have a periodic
image here anymore, which will skew the resulting power spectrum unless
you pad or taper. Using jpeg compression btw is also suboptimal for your
sinusoidal grating, as it will introduce artifacts in your pristine
frequency spectrum.

> > dimx=512
> > dimy=512
> > window, 1, xs=dimx, ys=dimy, title='original'
> > tvscl,image
> >
> > ;Power Spectrum F(u)*F^(u)
> > window, 2, xs=dimx, ys=dimy, title='Filtered Power Spectrum'
> > pspect= shift((fft(image, -1)*fft(conj(image),1)),dimx/2,dimy/2)

Inefficient (and strictly speaking wrong by a factor of 2) way to
calculate the power spectrum. Try

power = SHIFT(ABS(FFT(image, -1)), dimx/2, dimy/2)

instead. For any real world images, you'll also want to have a
logarithmic power spectrum for displaying purposes, i.e.

spectrum = FFT(image, -1)
zero_dB = ABS(spectrum(0,0))
power_dB = SHIFT(20. * ALOG10(ABS(spectrum) / zero_dB), dimx/2, dimy/2)

for a power spectrum in decibel with DC (mean gray value in the image)
as reference level.

If you check the "Raw Power Spectrum" and uncheck the "FFT Window"
checkboxes under Process->FFT->FFT Options in ImageJ, the resulting
power spectrum will _look_ the same as your IDL calculated one as a
result of the DC component being so dominant that it completely messes
up linear scaling.

Differences in the frequency noise are a mere artifact of the two
distinct implementations of the FFT algorithm.

HTH,
-Stefan
Reply | Threaded
Open this post in threaded view
|

Re: FFT of sinusoidal grating

Gabriele Umbriaco
Thanks, I have understood my error.
I am trying to confront the result of the FFT with that Power Spectrum
obtained to the focus of lens with parrallel beam and amplitude mask.
Gabriele


Stefan Heim ha scritto:

> Hi Gabriele,
>
> On Thu, 2008-10-02 at 11:45 +0200, Gabriele Umbriaco wrote:
>  
>> If I compute the FFT with ImageJ the result is not the same of IDL.
>> I do not understand because, it is wrong ?
>> You can help me?
>>    
>
> General advise: it takes a lot of caution and double-checking to compare
> FFT results from two distinct FFT implementations.
>
>  
>>> IDL code:
>>>
>>> ; IDL Version 5.2 (Win32 x86)
>>> ; Journal File for rockford@C3B0E6
>>> ; Working directory: D:\RSI\IDL52
>>> ; Date: Sat Jan 17 18:09:01 2004
>>> cd, 'C:\immagini'
>>> read_jpeg,'sin_grid_30.jpg',ima
>>> image=fltarr(512,512)
>>> image(*,*)=ima(1:512,1:512)
>>>      
>
> This looks suspicious. sin_grid_30.jpg is a periodic 800x800 pixel
> image, and you pick a 512x512 subimage, (accidentally?) offset by 1x1
> pixel (array indices in IDL are zero-based!). You don't have a periodic
> image here anymore, which will skew the resulting power spectrum unless
> you pad or taper. Using jpeg compression btw is also suboptimal for your
> sinusoidal grating, as it will introduce artifacts in your pristine
> frequency spectrum.
>
>  
>>> dimx=512
>>> dimy=512
>>> window, 1, xs=dimx, ys=dimy, title='original'
>>> tvscl,image
>>>
>>> ;Power Spectrum F(u)*F^(u)
>>> window, 2, xs=dimx, ys=dimy, title='Filtered Power Spectrum'
>>> pspect= shift((fft(image, -1)*fft(conj(image),1)),dimx/2,dimy/2)
>>>      
>
> Inefficient (and strictly speaking wrong by a factor of 2) way to
> calculate the power spectrum. Try
>
> power = SHIFT(ABS(FFT(image, -1)), dimx/2, dimy/2)
>
> instead. For any real world images, you'll also want to have a
> logarithmic power spectrum for displaying purposes, i.e.
>
> spectrum = FFT(image, -1)
> zero_dB = ABS(spectrum(0,0))
> power_dB = SHIFT(20. * ALOG10(ABS(spectrum) / zero_dB), dimx/2, dimy/2)
>
> for a power spectrum in decibel with DC (mean gray value in the image)
> as reference level.
>
> If you check the "Raw Power Spectrum" and uncheck the "FFT Window"
> checkboxes under Process->FFT->FFT Options in ImageJ, the resulting
> power spectrum will _look_ the same as your IDL calculated one as a
> result of the DC component being so dominant that it completely messes
> up linear scaling.
>
> Differences in the frequency noise are a mere artifact of the two
> distinct implementations of the FFT algorithm.
>
> HTH,
> -Stefan
>
>
>  

--
=================================================
Gabriele Umbriaco
Dipartimento di Astronomia, Universita` di Padova
Laboratorio d'ottica Padova/Asiago
vicolo dell'Osservatorio 3 I-35122 Padova, Italy
office: (+39) 049-8278215 fax: (+39) 049-8278212
laboratory PD: (+39) 049-8278213
laboratory AS: (+39) 0424-600058
email: [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: FFT of sinusoidal grating

Ben Tupper
Hi,

On the IDL side of things, you might find David Fanning's tutorial on  
frequency filtering useful.  Check it out at ...

http://dfanning.com/ip_tips/freqfiltering.html


Cheers,
Ben

On Oct 2, 2008, at 8:55 AM, Gabriele Umbriaco wrote:

> Thanks, I have understood my error.
> I am trying to confront the result of the FFT with that Power  
> Spectrum obtained to the focus of lens with parrallel beam and  
> amplitude mask.
> Gabriele
>
>
> Stefan Heim ha scritto:
>> Hi Gabriele,
>>
>> On Thu, 2008-10-02 at 11:45 +0200, Gabriele Umbriaco wrote:
>>
>>> If I compute the FFT with ImageJ the result is not the same of IDL.
>>> I do not understand because, it is wrong ?
>>> You can help me?
>>>
>>
>> General advise: it takes a lot of caution and double-checking to  
>> compare
>> FFT results from two distinct FFT implementations.
>>
>>
>>>> IDL code:
>>>>
>>>> ; IDL Version 5.2 (Win32 x86)
>>>> ; Journal File for rockford@C3B0E6
>>>> ; Working directory: D:\RSI\IDL52
>>>> ; Date: Sat Jan 17 18:09:01 2004
>>>> cd, 'C:\immagini'
>>>> read_jpeg,'sin_grid_30.jpg',ima
>>>> image=fltarr(512,512)
>>>> image(*,*)=ima(1:512,1:512)
>>>>
>>
>> This looks suspicious. sin_grid_30.jpg is a periodic 800x800 pixel
>> image, and you pick a 512x512 subimage, (accidentally?) offset by 1x1
>> pixel (array indices in IDL are zero-based!). You don't have a  
>> periodic
>> image here anymore, which will skew the resulting power spectrum  
>> unless
>> you pad or taper. Using jpeg compression btw is also suboptimal  
>> for your
>> sinusoidal grating, as it will introduce artifacts in your pristine
>> frequency spectrum.
>>
>>
>>>> dimx=512
>>>> dimy=512
>>>> window, 1, xs=dimx, ys=dimy, title='original'
>>>> tvscl,image
>>>>
>>>> ;Power Spectrum F(u)*F^(u)
>>>> window, 2, xs=dimx, ys=dimy, title='Filtered Power Spectrum'
>>>> pspect= shift((fft(image, -1)*fft(conj(image),1)),dimx/2,dimy/2)
>>>>
>>
>> Inefficient (and strictly speaking wrong by a factor of 2) way to
>> calculate the power spectrum. Try
>>
>> power = SHIFT(ABS(FFT(image, -1)), dimx/2, dimy/2)
>>
>> instead. For any real world images, you'll also want to have a
>> logarithmic power spectrum for displaying purposes, i.e.
>>
>> spectrum = FFT(image, -1)
>> zero_dB = ABS(spectrum(0,0))
>> power_dB = SHIFT(20. * ALOG10(ABS(spectrum) / zero_dB), dimx/2,  
>> dimy/2)
>>
>> for a power spectrum in decibel with DC (mean gray value in the  
>> image)
>> as reference level.
>>
>> If you check the "Raw Power Spectrum" and uncheck the "FFT Window"
>> checkboxes under Process->FFT->FFT Options in ImageJ, the resulting
>> power spectrum will _look_ the same as your IDL calculated one as a
>> result of the DC component being so dominant that it completely  
>> messes
>> up linear scaling.
>>
>> Differences in the frequency noise are a mere artifact of the two
>> distinct implementations of the FFT algorithm.
>>
>> HTH,
>> -Stefan
>>
>>
>>
>
> --
> =================================================
> Gabriele Umbriaco
> Dipartimento di Astronomia, Universita` di Padova
> Laboratorio d'ottica Padova/Asiago
> vicolo dell'Osservatorio 3 I-35122 Padova, Italy
> office: (+39) 049-8278215 fax: (+39) 049-8278212
> laboratory PD: (+39) 049-8278213
> laboratory AS: (+39) 0424-600058
> email: [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: FFT of sinusoidal grating

Michael Schmid
In reply to this post by Gabriele Umbriaco
Hi Gabriele,

a few more remarks:

for 512x512 your ImageJ result looks resonable, but you have
to note that the 8-bit image displayed as FFT is log-scaled
over many orders or magnitude. All kinds of numerical noise
will be seen in this image.
If you want the power spectrum, use Process>FFT>FFT options.
It will show the two peaks for the sine wave that one should
expect; the numerical noise will be many orders of magnitude
lower.

The IDL result for 512x512 looks like pure noise to me.
I have never used IDL, so I can't comment on your IDL script.

For the images that are not 2^n, ImageJ will extend the canvas
to 2^n size, in this case to 1024x1024. This results in sharp
edges that cause the light gray steaks in your FFT.
If you want to avoid this, scale the image to 2^n before.
Note this works for periodic boundary conditions only;
otherwise you need to multiply your image by some window
function that tapers off smoothly towards the edge (see
http://en.wikipedia.org/wiki/Window_function).
---

Here is a macro for testing that the power spectrum of ImageJ
is correct for a sum of two sine functions:

newImage("test", "32-bit Black", 256, 256, 1);
pi = 3.1415926536;
f1 = 2*2*pi/256;
f2 = 4*2*pi/256;

for (x=0; x<255; x++) {
   v = sin(f1*x)+0.5*cos(f2*x);
   setPixel(x, 0, v);
}
makeRectangle(0, 0, 256, 1);
run("Copy");
for (y=1; y<256; y++) {
   makeRectangle(0, y, 256, 1);
  run("Paste");
}
run("Select None");

run("FFT Options...", "fft raw do");

_____

Michael
________________________________________________________________

On 2 Oct 2008, at 11:45, Gabriele Umbriaco wrote:

> Good day to all.
> If I compute the FFT with ImageJ the result is not the same of IDL.
> I do not understand because, it is wrong ?
> You can help me?
> Thanks you.
> Gabriele
>
> ORIGINAL IMAGE 512x512 http://www.zshare.net/image/19808361cf9f18a5/
> IDL FFT 512x512 http://www.zshare.net/image/198083993bc66e61/
> IMAGEJ FFT 512x512 http://www.zshare.net/image/1980841949a36387/
>
> ORIGINAL IMAGE 800x800 http://www.zshare.net/image/1980603911fc4e4d/
> IDL FFT 800x800 http://www.zshare.net/image/198059600f47c99d/
> IMAGEJ FFT 800x800  http://www.zshare.net/image/198060136c636fcb/
>
>
>>
>> IDL code:
>>
>> ; IDL Version 5.2 (Win32 x86)
>> ; Journal File for rockford@C3B0E6
>> ; Working directory: D:\RSI\IDL52
>> ; Date: Sat Jan 17 18:09:01 2004
>> cd, 'C:\immagini'
>> read_jpeg,'sin_grid_30.jpg',ima
>> image=fltarr(512,512)
>> image(*,*)=ima(1:512,1:512)
>> dimx=512
>> dimy=512
>> window, 1, xs=dimx, ys=dimy, title='original'
>> tvscl,image
>>
>> ;Power Spectrum F(u)*F^(u)
>> window, 2, xs=dimx, ys=dimy, title='Filtered Power Spectrum'
>> pspect= shift((fft(image, -1)*fft(conj(image),1)),dimx/2,dimy/2)
>> tvscl, pspect
>>
>> write_jpeg, 'FFT_IDL.jpg', pspect, Quality=100
>> write_jpeg, 'sin_grid.jpg', image, Quality=100
>>
>> end
> =================================================
> Gabriele Umbriaco