[Insight-users] Local Image Filter (adaptative threshold)

Luis Ibanez luis.ibanez@kitware.com
Tue, 11 Feb 2003 17:50:35 -0500


Hi Mathieu,


The PlaheImageFilter expect images to
be of PixelType = float.

Please change the PixelType typedef in your code
to be:

   typedef    float   PixelType;


Let us know if you find further problems.


Thanks


    Luis


--------------------------------
Mathieu Malaterre wrote:

> Luis,
>  Thanks for pointing me out this filter but I am sorry I didn't manage 
> to get it to work:
> 
> Here is my code:
> 
> #include "itkPlaheImageFilter.h"
> #include "itkImageFileReader.h"
> #include "itkImageFileWriter.h"
> #include "itkImage.h"
> 
> int main( int argc, char ** argv )
> {
> 
>    // Verify the number of parameters in the command line
>  if( argc < 3 )
>    {
>    std::cerr << "Usage: " << std::endl;
>    std::cerr << argv[0] << " inputImageFile  outputImageFile " << 
> std::endl;
>    return -1;
>    }
>    typedef unsigned short      PixelType;
>  const   unsigned int        Dimension = 2;
>  typedef itk::Image<PixelType, Dimension> ImageType;
> 
>  typedef itk::PlaheImageFilter< ImageType >    PlaheType;
>  typedef itk::ImageFileReader< ImageType >    ReaderType;
>  typedef itk::ImageFileWriter< ImageType >    WriterType;
> 
>  PlaheType::Pointer plahe   = PlaheType::New();
>  ReaderType::Pointer reader = ReaderType::New();
>  WriterType::Pointer writer = WriterType::New();
> 
>  const char * inputFilename  = argv[1];
>  const char * outputFilename = argv[2];
> 
>  reader->SetFileName( inputFilename  );
>  writer->SetFileName( outputFilename );
> 
>  plahe->SetInput( reader->GetOutput() );
>  writer->SetInput( plahe->GetOutput() );
> 
> 
>  try {
>    // window[] is a neighborhood of a evaluated pixel
>    unsigned int window[Dimension];
>    window[0] = 9;
>    window[1] = 9;
> 
>    // Set window, alpha, and beta which are parameters for Plahe algorithm
>    std::cout << "Set Plahe parameters" << endl;
>    plahe->SetWindow(window);
>    plahe->SetAlpha(0.3);
>    plahe->SetBeta(0.3);
> 
>    writer->Update();
>  }
>  catch( itk::ExceptionObject & err ) {
>    std::cout << "ExceptionObject caught !" << std::endl;
>    std::cout << err << std::endl;
>    return -1;
>  }
> 
>  return 0;
> }
> 
> 
> And here is the error:
> 
> 
> /home/malat/Kitware/Insight/Code/BasicFilters/itkPlaheImageFilter.txx: 
> In method `void
> itk::PlaheImageFilter<TImageType>::GenerateData () [with TImageType = 
> main (int, char **)::ImageType]':
> /home/malat/Kitware/Insight/Code/Numerics/vxl/vnl/vnl_matrix_fixed_ref.h:50:   
> instantiated from here
> /home/malat/Kitware/Insight/Code/BasicFilters/itkPlaheImageFilter.txx:103: 
> no matching function for
> call to `itk::ImageRegionIterator<main (int, char 
> **)::ImageType>::ImageRegionIterator
> (itk::SmartPointer<itk::Image<float, 2> > &, itk::ImageRegion<2> &)'
> /home/malat/Kitware/Insight/Code/Common/itkImageRegionIterator.txx:30: 
> candidates are:
> itk::ImageRegionIterator<TImage>::ImageRegionIterator () [with TImage = 
> main (int, char **)::ImageType]
> /home/malat/Kitware/Insight/Code/Common/itkImageRegionIterator.txx:40:
> itk::ImageRegionIterator<TImage>::ImageRegionIterator (typename
> itk::ImageRegionConstIterator<TImage>::ImageType *, typename
> itk::ImageRegionConstIterator<TImage>::RegionType &) [with TImage = main 
> (int, char **)::ImageType]
> /home/malat/Kitware/Insight/Code/Common/itkImageRegionIterator.txx:51:
> itk::ImageRegionIterator<TImage>::ImageRegionIterator (const 
> itk::ImageIteratorWithIndex<TImage> &)
> [with TImage = main (int, char **)::ImageType]
> /home/malat/Kitware/Insight/Code/Common/itkImageRegionIterator.txx:59:
> itk::ImageRegionIterator<TImage>::ImageRegionIterator (const 
> itk::ImageRegionConstIterator<TImage> &)
> [with TImage = main (int, char **)::ImageType]
> /home/malat/Kitware/Insight/Code/Common/itkImageRegionIterator.h:46:
> itk::ImageRegionIterator<main (int, char 
> **)::ImageType>::ImageRegionIterator (const
> itk::ImageRegionIterator<main (int, char **)::ImageType> &)
> /home/malat/Kitware/Insight/Code/Numerics/vxl/vnl/vnl_matrix_fixed_ref.h:50:   
> instantiated from here
> /home/malat/Kitware/Insight/Code/BasicFilters/itkPlaheImageFilter.txx:113: 
> warning: passing `double'
> for argument 1 of `itk::ImageRegionIterator<TImage>::Set (typename
> itk::ImageRegionConstIterator<TImage>::PixelType &) const [with TImage = 
> main (int, char
> **)::ImageType]'
> /home/malat/Kitware/Insight/Code/Numerics/vxl/vnl/vnl_matrix_fixed_ref.h:50:   
> instantiated from here
> /home/malat/Kitware/Insight/Code/BasicFilters/itkPlaheImageFilter.txx:224: 
> no matching function for
> call to `itk::ImageRegionIterator<main (int, char 
> **)::ImageType>::ImageRegionIterator
> (itk::SmartPointer<itk::Image<float, 2> > &, itk::ImageRegion<2> &)'
> /home/malat/Kitware/Insight/Code/Common/itkImageRegionIterator.txx:30: 
> candidates are:
> itk::ImageRegionIterator<TImage>::ImageRegionIterator () [with TImage = 
> main (int, char **)::ImageType]
> /home/malat/Kitware/Insight/Code/Common/itkImageRegionIterator.txx:40:
> itk::ImageRegionIterator<TImage>::ImageRegionIterator (typename
> itk::ImageRegionConstIterator<TImage>::ImageType *, typename
> itk::ImageRegionConstIterator<TImage>::RegionType &) [with TImage = main 
> (int, char **)::ImageType]
> /home/malat/Kitware/Insight/Code/Common/itkImageRegionIterator.txx:51:
> itk::ImageRegionIterator<TImage>::ImageRegionIterator (const 
> itk::ImageIteratorWithIndex<TImage> &)
> [with TImage = main (int, char **)::ImageType]
> /home/malat/Kitware/Insight/Code/Common/itkImageRegionIterator.txx:59:
> itk::ImageRegionIterator<TImage>::ImageRegionIterator (const 
> itk::ImageRegionConstIterator<TImage> &)
> [with TImage = main (int, char **)::ImageType]
> /home/malat/Kitware/Insight/Code/Common/itkImageRegionIterator.h:46:
> itk::ImageRegionIterator<main (int, char 
> **)::ImageType>::ImageRegionIterator (const
> itk::ImageRegionIterator<main (int, char **)::ImageType> &)
> make[1]: *** [PlaheTest.o] Erreur 1
> make[1]: Quitte le répertoire 
> `/home/malat/Kitware/InsightBin/Applications/LocalRegionGrowingSegmentation' 
> 
> make: *** [default_target] Erreur 2
> 
> 
> What have done wrong ?
> 
> Thanks for any clue,
> mathieu
> 
>