[Insight-users] Variable dimension for vectors

Karthik Krishnan karthik.krishnan at kitware.com
Mon Feb 25 14:20:30 EST 2008


On 2/25/08, Vidya Rajagopalan <vidyaraj at vt.edu> wrote:
>
> Hello Everyone,
>
> When initializing an ITK vector, can I assign a variable dimension?
>
> eg:
>
>    int Dimension = NoOfInputs - 2;
>    typedef itk::Vector<float, Dimension> VectorPixelType;
>
> Should the dimension be a constant integer only?


No.

ITK itself provides several classes that can serve as Arrays or vectors.

1. FixedArray - Compile time fixed length arrays that's intended to
represent an enumerated collection of n entities.
2. Array - Run time resizeable array that is intended to hold a collection
of n entities
3. Vector - Compile time fixed length array that is intended to hold a
collection of n data types. A vector usually has a mathematical meaning. It
should only be used when mathematical operations such as addition,
multiplication by a scalar, product etc make sense.
4. VariableLengthVector - Run time array that is intended to hold a
collection of scalar data types. Again, it should be used only when
mathematical operations on it are relevant. If not, use an Array.

Now as far as instantiating images that use these datatypes...

1. You can instantiate an itk::Image< TPixelType, 3 > over any of the above
types.

2. You can also instantiate a itk::VectorImage< Type, 3 >. The resulting
image will behave just as itk::Image< VariableLengthVector< Type >, 3 >
would behave. It will provide faster memory access, consume less memory and
provide a less fragmented memory representation.

--
karthik

Vidya Rajagopalan
>
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20080225/715bce36/attachment.html


More information about the Insight-users mailing list