[Insight-users] itkGradientMagnitudeImageFilter

Chad Washington chad . w . washington at vanderbilt . edu
Thu, 22 May 2003 14:58:44 -0500


I am trying to use the GradientMagnitudeImageFilter with the following 
definitions:
typedef itk::Image<int, 2> InputImageType;
typedef itk::Image<float, 2> OutputImageType;
typedef itk::GradientMagnitudeImageFilter< InputImageType, OutputImageType > 
FilterType;

In my code I try to instantiate two objects of FilterType,
FilterType::Pointer filter1 = FilterType::New();
FilterType::Pointer filter2 = FilterType::New();

I receive the following errors at compilation:
Insight/Code/BasicFilters/itkGradientMagnitudeImageFilter.txx: In
   member function `void itk::GradientMagnitudeImageFilter<TInputImage,
   TOutputImage>::ThreadedGenerateData(itk::ImageToImageFilter<TInputImage,
   TOutputImage>::OutputImageRegionType&, int) [with TInputImage = ImageType,
   TOutputImage = FloatImageType]':
Insight/Code/Common/itkPointLocator.txx:161:   instantiated from here
Insight/Code/BasicFilters/itkGradientMagnitudeImageFilter.txx:163: no
   match for call to `(itk::NeighborhoodInnerProduct<ImageType, PixelType,
   PixelType>) (std::slice&, itk::ConstNeighborhoodIterator<ImageType,
   itk::ZeroFluxNeumannBoundaryCondition<ImageType> >&,
   itk::DerivativeOperator<float, 2, itk::NeighborhoodAllocator<float> >&)'
Insight/Code/Common/itkNeighborhoodInnerProduct.txx:32: candidates
   are: TComputation itk::NeighborhoodInnerProduct<TImage, TOperator,
   TComputation>::operator()(const std::slice&, const
   itk::ConstNeighborhoodIterator<TImage,
   itk::ZeroFluxNeumannBoundaryCondition<TImage> >&, const
   itk::Neighborhood<TOperator, itk::NeighborhoodInnerProduct<TImage,
   TOperator, TComputation>::ImageDimension,
   itk::NeighborhoodAllocator<TOperator> >&) const [with TImage = ImageType,
   TOperator = PixelType, TComputation = PixelType]
Insight/Code/Common/itkNeighborhoodInnerProduct.h:68:
            TComputation itk::NeighborhoodInnerProduct<TImage, TOperator,
   TComputation>::operator()(const itk::ConstNeighborhoodIterator<TImage,
   itk::ZeroFluxNeumannBoundaryCondition<TImage> >&, const
   itk::Neighborhood<TOperator, itk::NeighborhoodInnerProduct<TImage,
   TOperator, TComputation>::ImageDimension,
   itk::NeighborhoodAllocator<TOperator> >&) const [with TImage = ImageType,
   TOperator = PixelType, TComputation = PixelType]

To check to make sure this error was not a result of my implementation I 
edited 
Insight/Testing/Code/BasicFilters/itkGradientMagnitudeImageFilterTest.cxx by 
adding the line
typedef itk::Image<int, 2> InputImageType;
and editing the line
itk::GradientMagnitudeImageFilter<ImageType, ImageType>::Pointer 
        filter =
        itk::GradientMagnitudeImageFilter<ImageType, ImageType>::New();
to be
itk::GradientMagnitudeImageFilter<InputImageType, ImageType>::Pointer 
        filter =
        itk::GradientMagnitudeImageFilter<InputImageType, ImageType>::New();
I received the same errors.  I understand the reason for requiring the 
OutputImageType to be of PixelType float, but why does the InputImage have 
this requirement?
Thanks for your help,
Chad Washington
Biomedical Modeling Laboratory
Department of Biomedical Engineering
Vanderbilt University