[Insight-users] Flexible Vector Image class

Karthik Krishnan Karthik.Krishnan at kitware.com
Wed Nov 9 13:32:57 EST 2005


Folks at BWH ran into a similar problem.

There are multiple solutions here:

A.  You could live with an itk::Image< VariableLengthVector< float >, 3 >
  
This would create a 3D image with each pixel being a pointer to an 
VariableLengthVector, which is just an array of pixels. You could fill 
those pixels at run time. The length of each vector can be defined at 
run time.


B. Take a look at
http://www.itk.org/Insight/Doxygen/html/classitk_1_1VectorImage.html#_details

This creates an itk::VectorImage< float, 3 >

which is conceptually similar to
itk::Image< VariableLengthVector< float >, 3 >

The difference being that internally it does not store a pointer to an 
object of type VariableLengthVector, but the pixels themselves. This has 
2 advantages. It saves the extra bit of memory that you would incur if 
you stored an image of pointers, and it avoids fragmenting the memory 
space into thousands of tiny objects.  Again, you can set the length of 
the vectors in the image at run time. The VectorImage derives from 
itk::Image and behaves just like an itk::Image.

The SetVectorLength(int) method sets the length of the pixels at run time.

See Testing/Code/Common/itkVectorImageTest.cxx
http://www.itk.org/Insight/Doxygen/html/classitk_1_1VectorImageToImageAdaptor.html


HTH
Karthik

Dr. Uwe Köhler wrote:

>HiYa,
>
>while implementing a clustering algorithm for ITK (that we would like to 
>contribute), we hit a slight problem. Since we cluster images with different 
>contrasts (4 - 12) we have to recompile the code everytime we change the 
>number of contrasts. The length of vectors in a vector image has to be 
>templated at compile time. Did we miss anything here? Is there an elegant way 
>to define the number of vector dimensions in a vector image (dimension of the 
>vectors) at runtime? Could such a class be added to ITK?
>
>Any help and suggestions are very welcome.
>
>Cheers
>
>Uwe
>
>  
>


More information about the Insight-users mailing list