[Insight-users] How to compute min and max of VectorImage components

Kristen Zygmunt krismz at sci.utah.edu
Wed May 2 14:57:37 EDT 2012


Hello,
    I am trying to write code that will find the min and max values for each component of a VectorImage.  However, when I try to use VectorImageToImageAdaptor in combination with either MinimumMaximumImageFilter or MinimumMaximumImageCalculator, I get compile errors like the following:


/Volumes/Lion/LeopardLionShare/ITK_builds/denoising_ITK/Modules/Core/ImageAdaptors/include/itkImageAdaptor.hxx: In member function ‘const typename itk::ImageAdaptor<TImage, TAccessor>::InternalPixelType* itk::ImageAdaptor<TImage, TAccessor>::GetBufferPointer() const [with TImage = itk::VectorImage<float, 2u>, TAccessor = itk::Accessor::VectorImageToImagePixelAccessor<float>]’:
/Volumes/Lion/LeopardLionShare/ITK_builds/denoising_ITK/Modules/Core/Common/include/itkImageConstIteratorWithIndex.hxx:75:   instantiated from ‘itk::ImageConstIteratorWithIndex<TImage>::ImageConstIteratorWithIndex(const TImage*, const typename TImage::RegionType&) [with TImage = itk::VectorImageToImageAdaptor<float, 2u>]’
/Volumes/Lion/LeopardLionShare/ITK_builds/denoising_ITK/Modules/Core/Common/include/itkImageRegionConstIteratorWithIndex.h:160:   instantiated from ‘itk::ImageRegionConstIteratorWithIndex<TImage>::ImageRegionConstIteratorWithIndex(const TImage*, const typename itk::ImageConstIteratorWithIndex<TImage>::RegionType&) [with TImage = itk::VectorImageToImageAdaptor<float, 2u>]’
/Volumes/Lion/LeopardLionShare/ITK_builds/denoising_ITK/Modules/Core/Common/include/itkMinimumMaximumImageCalculator.hxx:55:   instantiated from ‘void itk::MinimumMaximumImageCalculator<TInputImage>::Compute() [with TInputImage = itk::VectorImageToImageAdaptor<float, 2u>]’
/Volumes/Lion/LeopardLionShare/ITK_builds/denoising_ITK/Modules/Filtering/Denoising/test/itkPixelTraitExplorationTest.cxx:279:   instantiated from ‘void itk::PixelExploration<TImage>::DispatchedVectorMinMax(const TImage*) [with TImage = itk::VectorImage<float, 2u>]’
/Volumes/Lion/LeopardLionShare/ITK_builds/denoising_ITK/Modules/Filtering/Denoising/test/itkPixelTraitExplorationTest.cxx:73:   instantiated from ‘void itk::PixelExploration<TImage>::ComputeMinMax(const itk::VectorImage<typename itk::NumericTraits<typename TInputImage::PixelType>::ValueType, itk::PixelExploration<TImage>::ImageDimension>*) [with TImage = itk::VectorImage<float, 2u>]’
/Volumes/Lion/LeopardLionShare/ITK_builds/denoising_ITK/Modules/Filtering/Denoising/test/itkPixelTraitExplorationTest.cxx:184:   instantiated from ‘void itk::PixelExploration<TImage>::Explore() [with TImage = itk::VectorImage<float, 2u>]’
/Volumes/Lion/LeopardLionShare/ITK_builds/denoising_ITK/Modules/Filtering/Denoising/test/itkPixelTraitExplorationTest.cxx:451:   instantiated from here
/Volumes/Lion/LeopardLionShare/ITK_builds/denoising_ITK/Modules/Core/ImageAdaptors/include/itkImageAdaptor.hxx:334: error: cannot convert ‘float*’ to ‘const itk::VariableLengthVector<float>*’ in return


Where it looks like the Iterators with index and the ImageAdaptor hierarchy are not playing nice together.  Am I missing something?  Is there another way to do this?


Here is a snippet of example code that fails to compile (I have attached the full test driver as well):

typedef float PixelValueType;
typedef VectorImage<PixelValueType, 2> ImageType;
const unsigned int numComponents = 3;

void DispatchedVectorMinMax(const ImageType* img)
{
    typedef VectorImageToImageAdaptor< PixelValueType, 2 > AdaptorType;
//     typedef MinimumMaximumImageFilter<AdaptorType>      MinMaxFilter;
    typedef MinimumMaximumImageCalculator<AdaptorType>      MinMaxCalculator;

    typename AdaptorType::Pointer adaptor = AdaptorType::New();
    adaptor->SetImage(const_cast<ImageType*>(img));

//     typename MinMaxFilter::Pointer minmax = MinMaxFilter::New();
    typename MinMaxCalculator::Pointer minmax = MinMaxCalculator::New();

    for (unsigned int cc = 0; cc <numComponents; ++cc)
    {
      adaptor->SetExtractComponentIndex(cc);
//       minmax->SetInput(adaptor);
      minmax->SetImage(adaptor);
//       minmax->Modified();
//       minmax->Update();
      minmax->Compute();

	std::cout << "Component " << cc << " min: " << minmax->GetMinimum()
                        << :, max: " << minmax->GetMaximum() << std::endl;
    }
  }


  ImageType::Pointer img1 = TImage::New();
  ImageType::IndexType indx; indx.Fill(0);
  ImageType::SizeType sz; sz.Fill(imageSz);
  ImageType::RegionType region(indx, sz);

  img1->SetRegions(region);
  img1->SetNumberOfComponentsPerPixel(numComponents);
  img1->Allocate();
  DispatchedVectorMinMax(img1.GetPointer());

-Kris

-------------- next part --------------
A non-text attachment was scrubbed...
Name: itkPixelTraitExplorationTest.cxx
Type: application/octet-stream
Size: 15270 bytes
Desc: not available
URL: <http://www.itk.org/pipermail/insight-users/attachments/20120502/91946ab9/attachment.obj>


More information about the Insight-users mailing list