[Insight-developers] Re: Vector image pixel type ?
Thielemans, Kris
kris.thielemans at csc.mrc.ac.uk
Sat Sep 24 01:43:46 EDT 2005
Hi Karthik
it's probably too late by now, but I do have a comment on this thread. Feel free to ignore it.
> Image< P, 3 >
>
> It would make sense for P to have a bunch of operations defined, so
> filters can work just as usual with it.
>
> For instance
> P1 + P2, P1*P2, P1*scalar, etc.....
>
> I would hesitate to add these operations to itk::Array, since its too
> general. People could for instance be using an Array of images or an
> array of transforms. You can't define any operations here. It the same
> reason why there is both itk::Vector and itk::FixedArray.
In another library, I was faced with exactly the same design decision. Do I add operator+ etc to the Array class or not?
At first go, I didn't, essentially because I didn't want to compilation to break when using a non-numeric type for P, which I believe is what you are saying as well. Then I remembered that as all this is with templates, and templated classes have the very useful property that their members are NOT compiled, unless you call them (or you instantiate the whole class explicitly obviously).
So, you can add operator+ to Array, and it won't break anything, even if you use std::vector for P.
So, I reversed my first design. I got rid of my 2nd class (let's call it NumericArray) and moved all its numerical operators to the Array class. Result: 1 class less to worry about, less lines of code, and exactly the same functionality. I still think that's the best thing to do.
PS: if you reply, please CC to my email address. I'm travelling and have disabled the list.
All the best
Kris Thielemans
Hammersmith Imanet, part of GE Healthcare
London, UK
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.itk.org/mailman/private/insight-developers/attachments/20050924/8158004e/attachment.htm
More information about the Insight-developers
mailing list