[Insight-users] Error while trying to read a vector image using VariableLengthVector
David Doria
daviddoria at gmail.com
Thu Nov 17 07:43:34 EST 2011
On Wed, Nov 16, 2011 at 7:40 PM, ravikiranj <ravikiran.j.127 at gmail.com> wrote:
>
> Hi all,
> I have run into a problem while trying to write/read vector images and I
> hope someone points me the right direction to solve my issue:-
>
> I need to write a 3D image where each pixel has 'k' (varies) values. Hence I
> created a dummy image of this by using VariableLengthVector and wrote the
> image.
>
> When I try to read the image back again, I get the below compile errors:-
> (sorry for the verbose error)
>
> In file included from
> /home/ravikiran/ITK/Modules/IO/Base/include/itkImageFileReader.h:25:0,
> from /home/ravikiran/vectorimg/VectorImage.cxx:11:
> /home/ravikiran/ITK/Modules/IO/Base/include/itkDefaultConvertPixelTraits.h:
> In static member function ‘static unsigned int
> itk::DefaultConvertPixelTraits<PixelType>::GetNumberOfComponents() [with
> PixelType = itk::VariableLengthVector<double>]’:
> /home/ravikiran/ITK/Modules/IO/Base/include/itkImageFileReader.hxx:398:5:
> instantiated from ‘void itk::ImageFileReader<TOutputImage,
> ConvertPixelTraits>::GenerateData() [with TOutputImage =
> itk::Image<itk::VariableLengthVector<double>, 3u>, ConvertPixelTraits =
> itk::DefaultConvertPixelTraits<itk::VariableLengthVector<double> >]’
> /home/ravikiran/vectorimg/VectorImage.cxx:67:1: instantiated from here
> /home/ravikiran/ITK/Modules/IO/Base/include/itkDefaultConvertPixelTraits.h:47:45:
> error: ‘GetNumberOfComponents’ is not a member of
> ‘itk::VariableLengthVector<double>’
> /home/ravikiran/ITK/Modules/IO/Base/include/itkDefaultConvertPixelTraits.h:
> In static member function ‘static void
> itk::DefaultConvertPixelTraits<PixelType>::SetNthComponent(int, PixelType&,
> const ComponentType&) [with PixelType = itk::VariableLengthVector<double>,
> itk::DefaultConvertPixelTraits<PixelType>::ComponentType = double]’:
> /home/ravikiran/ITK/Modules/IO/Base/include/itkConvertPixelBuffer.hxx:705:5:
> instantiated from ‘static void itk::ConvertPixelBuffer<InputPixelType,
> OutputPixelType, OutputConvertTraits>::ConvertVectorImage(InputPixelType*,
> int, OutputPixelType*, std::size_t) [with InputPixelType = unsigned char,
> OutputPixelType = itk::VariableLengthVector<double>, OutputConvertTraits =
> itk::DefaultConvertPixelTraits<itk::VariableLengthVector<double> >,
> std::size_t = long unsigned int]’
> /home/ravikiran/ITK/Modules/IO/Base/include/itkImageFileReader.hxx:528:3:
> instantiated from ‘void itk::ImageFileReader<TOutputImage,
> ConvertPixelTraits>::DoConvertBuffer(void*, std::size_t) [with TOutputImage
> = itk::Image<itk::VariableLengthVector<double>, 3u>, ConvertPixelTraits =
> itk::DefaultConvertPixelTraits<itk::VariableLengthVector<double> >,
> std::size_t = long unsigned int]’
> /home/ravikiran/ITK/Modules/IO/Base/include/itkImageFileReader.hxx:418:7:
> instantiated from ‘void itk::ImageFileReader<TOutputImage,
> ConvertPixelTraits>::GenerateData() [with TOutputImage =
> itk::Image<itk::VariableLengthVector<double>, 3u>, ConvertPixelTraits =
> itk::DefaultConvertPixelTraits<itk::VariableLengthVector<double> >]’
> /home/ravikiran/vectorimg/VectorImage.cxx:67:1: instantiated from here
> /home/ravikiran/ITK/Modules/IO/Base/include/itkDefaultConvertPixelTraits.h:55:5:
> error: ‘class itk::VariableLengthVector<double>’ has no member named
> ‘SetNthComponent’
> make[2]: *** [CMakeFiles/VectorImage.dir/VectorImage.cxx.o] Error 1
> make[1]: *** [CMakeFiles/VectorImage.dir/all] Error 2
> make: *** [all] Error 2
>
> I have attached the .cxx and the CMakeLists.txt file. Is there something
> wrong I'm doing in the code ? I cannot use VectorImage as I don't know the
> no. of components I need to store per pixel at compile time.
>
> Please let me know if anything is unclear.
> http://old.nabble.com/file/p32858761/VectorImage.cxx VectorImage.cxx
> http://old.nabble.com/file/p32858761/CMakeLists.txt CMakeLists.txt
Your code compiles fine for me. Also, VectorImage is exactly an
itkImage with pixels of type VariableLengthVector - i.e. these two
things are the same:
typedef itk::Image< itk::VariableLengthVector< PixelType >,
Dimension > VariableLengthVectorImageType;
typedef itk::VectorImage< PixelType, Dimension > VectorImageType;
"I cannot use VectorImage as I don't know the no. of components I need
to store per pixel at compile time."
This is exactly the time when you SHOULD use VectorImage :)
David
More information about the Insight-users
mailing list