[Insight-users] Error while trying to read a vector image using VariableLengthVector

ravikiranj ravikiran.j.127 at gmail.com
Sat Nov 19 20:09:22 EST 2011


Also, whenever a vector image is instantiated, we specify a vector length
i.e, SetVectorLength(l) which ensures that each of the pixel has the same
length vector and I've been unsuccessful in changing the vector size
dynamically :(. Would be possible to write a code snippet where I can write
a variable no. of components per pixel, save it and read it back again, I've
been stuck with this issue for a week now without any visible solution than
writing a custom file format (text file).

Regards,
 Ravikiran


daviddoria wrote:
> 
> 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
> _____________________________________
> 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
> 
> 

-- 
View this message in context: http://old.nabble.com/Error-while-trying-to-read-a-vector-image-using-VariableLengthVector-tp32858761p32868855.html
Sent from the ITK - Users mailing list archive at Nabble.com.



More information about the Insight-users mailing list