[Insight-developers] Gaussian filters

mark foskey foskey at cs . unc . edu
Wed, 24 Jul 2002 11:18:48 -0400


I'm new to the group and still learning ITK, and I've noticed a couple
of apparent anomalies with the various Gaussian filter classes.

1. RecursiveGaussianImageFilter has a SetSigma method, while 
DiscreteGaussianImageFilter has a SetVariance method.  I think it would 
be helpful if the method were the same in both filters.

2. DiscreteGaussianImageFilter yielded an apparently blank image for all 
variance values I tried other than 0.  I am including the test program I 
used below.  I may be doing something wrong.

3. Perhaps most serious is that it was hard to figure out how to use 
these filters from their documentation.  Programmers are likely to 
assume that RecursiveGaussianImageFilter simply blurs an image; only if 
they read the documentation for RecursiveSeparableImageFilter will they 
learn that the filter must be applied once for each dimension.  Also, 
for DiscreteGaussianImageFilter, the SetMaximumError method isn't 
documented.  I'm not clear on what the m_MaximumError parameter controls 
in this context.  I have not read the code yet, but the point is that I 
think the meaning of the parameter should be documented.

4. It would be nice if there were a convenience filter that would 
internally chain together instances of the RecursiveGaussianImageFilter 
for each dimension, since most users will want to filter along all n dims.

I'm sorry for my first message to the group to come across as a 
complaint, but I'm seeing ITK somewhat as a new user will, and I think 
we have to be aware things that frustrate beginners.

Here's the test program:

#include <itkImage.h>
#include <itkImageFileReader.h>
#include <itkImageFileWriter.h>
#include <itkPNGImageIO.h>
#include <itkDiscreteGaussianImageFilter.h>

typedef itk::Image<unsigned char, 2> ImageType ;

int main(int argc, char* argv[])
{
      if (argc < 2)
      {
          std::cout
              << "usage: VerySimpleFilter [inputfile] [outputfile]"
              << std::endl;
          exit(0);
      }

      // Create an IO object for PNG files, to be used by both the
      // reader and the writer.
      typedef itk::PNGImageIO PNGIOType;
      PNGIOType::Pointer png = PNGIOType::New();

      // Instantiate a reader for the file.
      typedef itk::ImageFileReader<ImageType> ImageReaderType;
      ImageReaderType::Pointer reader = ImageReaderType::New();
      reader->SetImageIO(png);
      reader->SetFileName(argv[1]);

      // Instantiate a filter and attach it to the reader.
      typedef itk::DiscreteGaussianImageFilter<ImageType, ImageType>
          GaussianFilterType;
      GaussianFilterType::Pointer myFilter = GaussianFilterType::New();
      myFilter->SetInput(reader->GetOutput());
      myFilter->SetVariance(0.1);

      // Instantiate a writer and attach it to the filter.
      typedef itk::ImageFileWriter<ImageType> ImageWriterType;
      ImageWriterType::Pointer writer = ImageWriterType::New();
      writer->SetImageIO(png);
      writer->SetInput(myFilter->GetOutput());
      writer->SetFileName(argv[2]);

      writer->Write();

      return 0;

}
-- 
Mark Foskey    (919) 843-5436   Computer-Aided Diagnosis and Display Lab
mark_foskey@unc.edu             Department of Radiology, CB 7515, UNC
http://www.cs.unc.edu/~foskey   Chapel Hill, NC  27599-7515