[Insight-developers] instantiating itkVector

Luis Ibanez luis.ibanez at kitware.com
Sat Dec 6 17:55:21 EST 2008


Richard,

You may have to consider how visible this class is supposed to be
and what performance implications you can anticipate from its
construction (e.g. is the type of class that you will use to
create thousands of instances in an inner loop ?).

Using one of vcl vector classes that you can resize at run-time
is definitely an option. It is worth to write a small use case
example to see which one will work better.

Note as well that ITK has the variable length vector, whose
size can be defined at run time.


    Regards,


        Luis

--------------------
Richard Beare wrote:
> Am I likely to be better off using underlying vcl classes directly?
> Will that give me more flexibility?
> 
> On Sat, Dec 6, 2008 at 4:26 AM, Luis Ibanez <luis.ibanez at kitware.com> wrote:
> 
>>Hi Richard,
>>
>>Thanks for the clarification.
>>
>>
>>This is good news and bad news  :-)
>>
>>
>>
>>The good news is that you know the number at compile time,
>>since that is what the itkVector instantiation will require.
>>
>>The bad news is that the expression that you need to evaluate
>>for computing the vector size is a non-trivial one.
>>
>>
>>One potential way of generating that computation would be to
>>have a Traits helper class, at the image of the NumericTraits
>>class.
>>
>>In this helper class you could define explicit instantiations
>>such that an internal enum (or static int) will be initialized
>>to the value of 3^(N-1).
>>
>>This is a bit manual, but I'm assuming that you would not need
>>more that dimensions in the range N=1,2,3,4,5 ... (?).
>>So you will be done with the Traits in a couple of copy/pasting
>>sessions, and in less than 50 lines of code.
>>
>>There are probably smarter ways of getting this to work,
>>but more coffee may be required for figuring them out...
>>
>>
>>    Regards,
>>
>>
>>        Luis
>>
>>
>>
>>----------------------
>>Richard Beare wrote:
>>
>>>Hi,
>>>
>>>In this case I'll know it at compile time - it is dependent on the
>>>dimensionality of the image. Actually, to be specific, it is given by
>>>3^(ImType::ImageDimension - 1).
>>>
>>>It would probably look neater in the code if I could do it in a way
>>>that was not dependent on compile time knowledge, but I'm not sure
>>>that is possible. I'll need to do something equivalent with matrix
>>>types too.
>>>
>>>On Fri, Dec 5, 2008 at 12:50 AM, Luis Ibanez <luis.ibanez at kitware.com>
>>>wrote:
>>>
>>>
>>>>Richard,
>>>>
>>>>
>>>>Would you know the size of the neighborhood at compilation time ?
>>>>
>>>>or only at run-time ?
>>>>
>>>>
>>>>Please let us know,
>>>>
>>>>
>>>> Thanks
>>>>
>>>>
>>>>   Luis
>>>>
>>>>
>>>>----------------------
>>>>Richard Beare wrote:
>>>>
>>>>
>>>>>Hi,
>>>>>I need to create a vector type with length equal to the size of a
>>>>>neighborhood - i.e. 3^ImageDimension. I suspect that there needs to be
>>>>>some sort of trick with macros, because calling pow is no good. Any
>>>>>suggestions?
>>>>>
>>>>>Thanks
>>>>>_______________________________________________
>>>>>Insight-developers mailing list
>>>>>Insight-developers at itk.org
>>>>>http://www.itk.org/mailman/listinfo/insight-developers
>>>>>
>>>>
> 


More information about the Insight-developers mailing list