[Insight-users] Extract component from vector image, deformable model

Benjamin Klimczak klimczaks at gmx.de
Wed Jul 15 12:56:13 EDT 2009


Hello everybody.

It would be great if someone could help me out here. I'm new to ITK and I'm trying to get the Deformable Model Filter running as it is described in the ItkSoftwareGuide. A Problem is that the input and output mesh of the filter are identical. If anybody has an idea why that could be, I'd be happy to hear it. 
But the problem I have right now is that I want to check if the gradient (input of the deformable model filter) looks reasonable. To do that I want to extract one component from the gradient image (an itk::Image with covariant vectors as PixelType) so that I can view it as an grey scale image. To do that I've tried to use VectorImageToImageAdaptor with the output of ImageToVectorImageFilter as input for the adaptor. A part of the code I'm using can be found below. If I try to compile it Visual Studio 2008 puts out the error below (I have translated it into english, i.e. it's not the original english output). I have tried some reinterpret_casts and variants of the code below but nothing works. It always ends with template errors from the compiler. (I have also tried VectorToRGBImageAdaptor but this didn't work either.)

Thanks for any help
Benjamin

Code excerpt
##################################################################################################

  [...]
  const unsigned int Dimension = 3;

  typedef itk::CovariantVector<double, Dimension> VectorPixelType;
  typedef itk::Image<VectorPixelType, Dimension> GradientImageType3D;

  typedef itk::GradientRecursiveGaussianImageFilter<InputImageType3D, GradientImageType3D> GradientFilterType;

  GradientFilterType::Pointer GradientFilter = GradientFilterType::New();
  GradientFilter->SetInput( GradientMagnitudeFilter->GetOutput() );
  GradientFilter->SetSigma(1.0);

  // Create a VectorImage from the input Image (that has a covariant vector as PixelType)
  typedef itk::ImageToVectorImageFilter<GradientImageType3D> ImageToVectorImageFilterType;
  ImageToVectorImageFilterType::Pointer imageToVectorImageFilter = ImageToVectorImageFilterType::New();
  imageToVectorImageFilter->SetInput(GradientFilter->GetOutput());

  try
  {
    imageToVectorImageFilter->Update();
  }
  catch( itk::ExceptionObject & excep )
  {
    [...]
  }

  // Get accesss to one image from the VectorImage with the VectorImageToImageAdaptor
  typedef itk::VectorImageToImageAdaptor<VectorPixelType, Dimension> ImageAdaptorType;
  ImageAdaptorType::Pointer imageAdaptor = ImageAdaptorType::New();
  imageAdaptor->SetImage(imageToVectorImageFilter->GetOutput());
  imageAdaptor->SetExtractComponentIndex(0);

  [...]
##################################################################################################



Compiler Output
##################################################################################################

e:\insighttoolkit-3.14.0\code\common\itkImageAdaptor.txx(334) : error C2440: 'return': cannot convert 'itk::CovariantVector<T,NVectorDimension> *' to 'const itk::VariableLengthVector<TValueType> *'
        with
        [
            T=double,
            NVectorDimension=3
        ]
        and
        [
            TValueType=itk::CovariantVector<double,3>
        ]
        These types are not connected, conversion needs reinetrpret_cast or c-type cast
        e:\insighttoolkit-3.14.0\code\common\itkImageAdaptor.txx(333): While compiling the class template of const itk::VariableLengthVector<TValueType> *itk::ImageAdaptor<TImage,TAccessor>::GetBufferPointer(void) const-Memberfunction
        with
        [
            TValueType=itk::CovariantVector<double,3>,
            TImage=itk::VectorImage<itk::CovariantVector<double,3>,3>,
            TAccessor=itk::Accessor::VectorImageToImagePixelAccessor<VectorPixelType>
        ]
        e:\insighttoolkit-3.14.0\code\common\itkImageAdaptor.txx(66): While compiling the class template of void itk::ImageAdaptor<TImage,TAccessor>::SetPixelContainer(itk::ImportImageContainer<TElementIdentifier,TElement> *)-Memberfunction
        with
        [
            TImage=itk::VectorImage<itk::CovariantVector<double,3>,3>,
            TAccessor=itk::Accessor::VectorImageToImagePixelAccessor<VectorPixelType>,
            TElementIdentifier=unsigned long,
            TElement=itk::CovariantVector<double,3>
        ]
        e:\insighttoolkit-3.14.0\code\common\itkImageAdaptor.txx(399): While compiling the class template of void itk::ImageAdaptor<TImage,TAccessor>::SetLargestPossibleRegion(const itk::ImageRegion<VImageDimension> &)-Memberfunction
        with
        [
            TImage=itk::VectorImage<itk::CovariantVector<double,3>,3>,
            TAccessor=itk::Accessor::VectorImageToImagePixelAccessor<VectorPixelType>,
            VImageDimension=3
        ]
        E:\InsightToolkit-3.14.0\Code\Common\itkVectorImageToImageAdaptor.h(111): See reference to the instantiation of the just compiled class template "itk::ImageAdaptor<TImage,TAccessor>".
        with
        [
            TImage=itk::VectorImage<itk::CovariantVector<double,3>,3>,
            TAccessor=itk::Accessor::VectorImageToImagePixelAccessor<VectorPixelType>
        ]
        ..\..\..\mitk-0.12.2\Bundles\my.domain.mean\src\internal\QmitkMeanPluginView.cpp(258): See reference to the instantiation of the just compiled class template "itk::VectorImageToImageAdaptor<TPixelType,Dimension>".
        with
        [
            TPixelType=VectorPixelType,
            Dimension=3
        ]
        ..\..\..\mitk-0.12.2\Bundles\my.domain.mean\src\internal\QmitkMeanPluginView.cpp(154): See reference to the instantiation of the just compiled function template "void QmitkMeanPluginView::ItkImageProcessing<double,2>(itk::Image<TPixel,VImageDimension> *)".
        with
        [
            TPixel=double,
            VImageDimension=2
        ]

##################################################################################################

-- 
Neu: GMX Doppel-FLAT mit Internet-Flatrate + Telefon-Flatrate
für nur 19,99 Euro/mtl.!* http://portal.gmx.net/de/go/dsl02


More information about the Insight-users mailing list