[Insight-users] (Fast) Fourier Filters
Luis Ibanez
luis . ibanez at kitware . com
Sun, 26 May 2002 14:00:41 -0400
Hi Bjorn,
1) We don't have an FFT filter in ITK yet.
The element for creating one are all there though.
VNL (the mathematical library used in ITK) provides
a ready to use fft function for 1D:
http://www.itk.org/Insight/Doxygen/html/classvnl__fft1d.html
So, an easy implementation could be done by using the
same infrastructure of the RecursiveSeparableImageFilter
because it is a separable filter applied line by line,
which is the same approach required for an FFT.
http://www.itk.org/Insight/Doxygen/html/classitk_1_1RecursiveSeparableImageFilter.html
However, FFT requires some additional machinery,
and brings up some design issues, for example:
The output of an FFT is an image whose pixels
are complex and could be represented by:
1.1) ITK images are templated over pixel type
so we can easily create itk::Image< complex<float>,3>
1.2) An alternative representation is to produce two
escalar images with real and imaginary parts.
1.3) yet another approach is to produce two escalar
images with magnitude and phase.
We could probably take 1.1, that is, using native
complex images and adress 1.2 and 1.3 by using ImageAdaptors
and ImageFilters. ImageAdaptors will easily allow to access
the real or imaginary part of a complex image as it the image
were has a scalar component. See for example the use of Adaptors
in RGB images for getting access to one of the channels:
Insight/Testing/Code/Common/itkImageAdaptorTest.cxx
Filters for extracting {real/imaginary/magnitud/phase} from
complex pixels can be easile implemented using the
UnaryFunctorImageFilter:
Insight/Code/BasicFilters/itkUnaryFunctorImageFilter.h
It is enough to add a Functor class defining how the input
complex pixel should be converted into an output scalar value.
See for example:
Insight/Code/BasicFilters/itkSinImageFilter.h
2) An FFT is maybe not what you need. According to
your email, you want to smooth a binary image and
remove holes an peaks.
2.1) This sounds like a good match for Mathematical
Morphology operators. A sequence of erosion and dilation
(also known as an openning or closing operation depending
on how you defined your object and background on the
binary image). The available filters are described in:
http://www.itk.org/Insight/Doxygen/html/group__MathematicalMorphologyImageFilters.html
Note that some of them are GrayScale, so you can apply them
before thresholding your output (although in theory,
thresholding and erosion/dilation are commutative operators).
These filters use a clever approach involving the Neighborhood
operators designed and implemented by Josh Cates at Utah.
The median filter also use neighborhood operators but requires
less computations per neighborhood than the Median filter.
2.2) You may also take advantage of the recently
added filter:
http://www.itk.org/HTML/AntiAliasBinaryImageFilterExample.html
http://www.itk.org/Insight/Doxygen/html/classitk_1_1AntiAliasBinaryImageFilter.html
but Morphological Operators will probably give you a better
performance.
Please let us know if you find an acceptable alternative,
Thanks
Luis
=========================================
Bjorn Hanch Sollie wrote:
> Is there a fourier-filter implemented in ITK? I was looking for it
> but I didn't find anything. Are there any recommended ways of
> implementing it if it's not already there?
>
> I have performed some fast march and level set segmentation, and the
> results so far look very promising! However, I need to smooth the
> binary output images I get in order to remove small "holes" inside the
> segmented region and sharp peaks and gaps along the edges. A median
> filter does this very very well, practically to the point of being
> ideal for the purpose, but it takes a bit (too) long to run,
> unfortunately. A gaussian, for example, doesn't perform nearly as
> well.
>
> Aside from medians and fouriers, are there any other filters in ITK
> that are particularly suited for such a task?
>
> Finally, a big thanks goes to Luis Ibanez and everyone else on this
> list who have patiently answered my questions (you know who you are).
> I wouldn't have made it this far without your help.
>
> -Bjorn
>