Login  Register

Re: Fourier transform and filtering

Posted by Antonio on Oct 29, 2008; 9:41pm
URL: http://imagej.273.s1.nabble.com/Fourier-transform-and-filtering-tp3694627p3694629.html

Michael Schmid-3 wrote
First, it is very important to note that the values (in pixels) in  
"Bandpass filter" are *half* of the spatial frequencies that you can  
read from the status line when moving the cursor over the FFT image.
That's because "structure size" means size of, e.g., a bright  
particle; and the lowest strong Fourier component is that where the  
upper half-cycle of the sinewave corresponds to the particle, the  
negative "surrounding" correspond to the background.

Just in case this is not clear: The values in pixels in "bandpass  
filters" are in real space, i.e., pixels of the image. The scale of  
the custom filter is in frequency space. 1 pixel from the origin  
(center) corresponds to one period per image size, 2 pixels from the  
origin corresponds to two cycles per image size, etc. For images that  
are not 2^n*2^n, "image size" here means the lowest value of 2^n that  
'is not smaller than width and height.
Thanks for replying.

Concerning the right frequencies to select, I dealt directly with the problem doing the following: before taking the pictures of interest, I shot one of an object of known size, so I know the actual ratio pixel/cm. Then, the smallest wave vector allowed in my system being q_min = 2*3,14/(image_size_cm), each pixel of the transformed image (or of the filter) will correspond to a wave vector of q = q_min*(pixel_from_center)*R.
R has to be equal to (image_size)/(transformed_size), so on the borders of the transformed image I can retrieve half the maximum wave vector allowed, since to span the whole spectrum both -q and +q are needed.
With this, I can arrange a custom filter at the right frequency, or check the wave vectors selected by a given bandpass filter. So, if I'm not doing a mistake, this way of using a filter should yield the right frequency.
I tested this calibration by transforming via FFT a dummy circle, then obtaining an Airy frequency pattern and eventually checking the position of the first dark ring (it occurs at pixels which 'carry' a wave vector value in accord with theory).

If you run "FFT" or "Custom Filter" you will get edge artifacts,  
usually visible in the power spectrum as horizontal and vertical  
lines through the origin (center). The bandpass filter in ImageJ  
continues the image outside the image area with its mirrored  
counterpart to avoid any jumps at the edges, greatly reducing such  
artifacts.
When selecting "Display Filter" of the bandpass filter, with image  
sizes of 2^n or somewhat smaller, you will also see that the filter  
size (equal to the size of the input image) is 2*2^n, due to the  
space needed for the mirrored-image continuation. In this case, you  
have to downscale the filter created by "Display Filter" by a factor  
of 2 before using it as a custom filter.
I started using bandpass filtering, then I switched to custom filtering for at least two reason: one of my purposes is to effectively remove the 0-frequency component, and I found the filters provided rather too spread (the cutoff is too soft, as you said).
I was unaware of the bandpass 'size duplication', but it is still a little unclear to me.
Do you mean that the bandpass filtering actually doubles the allowed frequency range, so to reduce the edge noise, or that the real image is padded so to place the 'true' pixels in a range of spatial structures that are better reconstructed?
Still, if it's a matter of avoiding artifacts, or rescaling by 2 the bandpass filter, I'm not so sure it can fully account for the inconsistency I see (as I simply tried to make manually the same frequency selection that 'custom filter' should be performing *as far as I know*); anyway your explanation has been useful, I'm going to do a bit of work on bandpass filtering as well.

Antonio