[Insight-developers] Wrong behaviour of ImageFileReader when reading an itk::VectorImage<itk::FixedArray<double, 6>, 3> ?
Bradley Lowekamp
blowekamp at mail.nih.gov
Mon Jan 17 13:17:44 EST 2011
Hello,
On Jan 17, 2011, at 12:18 PM, Karthik Krishnan wrote:
> Benoit:
>
> Do you have a variable number of tensors at each pixel ? If not, You should simply declare your image as
>
> Image< Vector< DiffusionTensor< double >, N >, 3 >
I think you intended to say that if you only have one Tensor per pixel then you should declare the image types as follows:
Image< itk::DiffusionTensor3D<double>, 3> ImageOfTensorType;
As opposed to:
typedef itk::VectorImage<itk::DiffusionTensor<double>,3> ImageOfVariableNumberOfTensorsType;
or
typedef Image<Vector<DiffusionTensor<double, 3>, N >, 3> ImageOfNTensorsType;
More information on VectorImage can be found here:
http://www.itk.org/Doxygen/html/classitk_1_1VectorImage.html#_details
>
> The whole intent of the VectorImage was to avoid memory fragmentation by internally storing images of the type
> Image< Array< double >, 3 >
> as a contiguous set of N doubles for the array, instead of a pointer to the data at each pixel and the length of the data at each pixel (itk::Array< double > has a pointer to the data and an integer to represent the length of the pixel.). The resulting image will behave just as itk::Image< Array< double >, 3 > would behave. It will provide faster memory access, consume less memory and provide a less fragmented memory representation.
>
> By contrast, the compile time classes, ie Vector and DiffusionTensor are equivalent to a C array, and 0 overhead.
>
> -
> karthik
>
>
> On Mon, Jan 17, 2011 at 9:16 PM, Benoit Scherrer <benoitscherrer at gmail.com> wrote:
> Ok thanks!
>
> But so there is no way to use:
> typedef itk::VectorImage<itk::DiffusionTensor<double>, 3> TensorVectorImage;
> to read a set of tensors at each voxel ?
> ( itk::DiffusionTensor inherits itk::FixedArray)
>
> It would be useful to do for example:
>
> TensorVectorImage tensors;
> tensors[i].GetFractionalAnisotropy()
>
> Thanks
> Benoit
>
>
> On Thu, Jan 13, 2011 at 11:26 PM, Karthik Krishnan <karthik.krishnan at kitware.com> wrote:
>
>
> On Fri, Jan 14, 2011 at 6:26 AM, Benoit Scherrer <benoitscherrer at gmail.com> wrote:
> Hi,
>
> I wanted to use the type:
> typedef itk::VectorImage<itk::FixedArray<double, 6>, 3> TensorVectorImage;
> to make a vector image of tensors.
>
> Everything compiles well. But when i use the itk::ImageFileReader<TensorVectorImage>
> it seems that things goes wrong. When trying to iterate on the image :
>
> itk::ImageRegionConstIterator<TensorVectorImage> it(image, image->GetLargestPossibleRegion());
> while(!it.IsAtEnd())
> {
> itk::VariableLengthVector<itk::FixedArray<double, 6> > tensors = it.Get();
> (...)
> ++it;
> }
>
> it compiles but during the execution goes out of the data bounds.
>
> By looking into ImageFileReader<TOutputImage, ConvertPixelTraits>::GenerateOutputInformation
> I found the lines:
>
> if( strcmp( output->GetNameOfClass(), "VectorImage" ) == 0 )
> {
> typedef typename TOutputImage::AccessorFunctorType AccessorFunctorType;
> AccessorFunctorType::SetVectorLength( output, m_ImageIO->GetNumberOfComponents() );
> }
>
> So here m_ImageIO->GetNumberOfComponents() will returns 6 for a simple tensor file (Dimension
> of the VectorImage = 1), instead of 1 (after the offsets computed in ImageRegionConstIterator are wrong).
>
> So should ImageFileReader divides m_ImageIO->GetNumberOfComponents() by the number of components
> of TOutputImage::PixelType ? (i manually set it to 1 in the debugger, it's working. However i didn't tried
> with an image with 12 components, ie two tensors)
>
> Or is it a bad idea to use itk::VectorImage<itk::FixedArray<double, 6>, 3> ?
>
> To make a VectorImage of tensors, you declare it simply as itk::VectorImage< double, 3 > and set the VectorLength on the image to 6.
>
> Or you could use itk::Image< FixedArray< double, 6 >, 3 >.
>
> The two are equivalent.
>
>
>
> Thanks a lot
> Benoit
>
>
> _______________________________________________
> 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://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-developers
>
>
>
>
>
> --
> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
> Benoit Scherrer
> Postdoctoral Research Fellow
> Computational Radiology Laboratory,
> Harvard Medical School (Boston)
>
> http://www.crl.med.harvard.edu/
> http://www.BenoitScherrer.com
> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
>
> <ATT00001..txt>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/mailman/private/insight-developers/attachments/20110117/ef324eb4/attachment.htm>
More information about the Insight-developers
mailing list