[Insight-users] Iterating over an adaptor?

Bill Lorensen bill.lorensen at gmail.com
Tue Nov 1 11:03:08 EDT 2011


David,

This test:

Modules/Core/ImageAdaptors/test/itkVectorImageTest.cxx uses iterators on
vector adaptors.

Bill

On Tue, Nov 1, 2011 at 9:11 AM, David Doria <daviddoria at gmail.com> wrote:

> If I create an adaptor to represent one channel of a vector image:
>
> typedef itk::VectorImage<float, 2> VectorImageType;
>
>   VectorImageType::Pointer image = VectorImageType::New();
>   ... Create image ...
>
>   typedef itk::VectorImageToImageAdaptor<float, 2> ImageAdaptorType;
>   ImageAdaptorType::Pointer adaptor = ImageAdaptorType::New();
>   adaptor->SetExtractComponentIndex(0);
>   adaptor->SetImage(image);
>
> And then try to create an iterator:
>
>   itk::ImageRegionIterator<ImageAdaptorType> imageIterator(adaptor,
> adaptor->GetLargestPossibleRegion());
>
> I get this error:
>
> itkImageAdaptor.hxx:334:36: error: cannot convert ‘itk::VectorImage<float,
> 2u>::InternalPixelType* {aka float*}’ to ‘const InternalPixelType* {aka
> const itk::VariableLengthVector<float>*}’ in return
>
> I also tried using the resulting scalar image type for the iterator:
>
> typedef itk::Image<float, 2> ScalarImageType;
> itk::ImageRegionIterator<ScalarImageType> imageIterator(adaptor,
> adaptor->GetLargestPossibleRegion());
>
> but of course I get this error:
> VectorImageToImageAdaptor.cxx:35:103: error: no matching function for call
> to ‘itk::ImageRegionIterator<itk::Image<float, 2u>
> >::ImageRegionIterator(itk::VectorImageToImageAdaptor<float, 2u>::Pointer&,
> const RegionType&)’
>
> Is it not possible to iterate over an adaptor like this?
>
> Thanks,
>
> David
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>
>


-- 
Unpaid intern in BillsBasement at noware dot com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20111101/a9f6e2f2/attachment.htm>


More information about the Insight-users mailing list