[Insight-developers] ImageIO & supported Pixel types -- TMP programming challenge

Bradley Lowekamp blowekamp at mail.nih.gov
Fri Nov 12 07:00:48 EST 2010


Hello,

One thing that should be able to make this easier is the new NumericTraits::GetLength( pixel ) attribute. And then the component type can be determined by NumericTraits::ValueType. This in combination with the tr1::type_traits, should make it much easier.

Just need tr1.

Brad

On Nov 12, 2010, at 2:13 AM, wanlin wrote:

> HI, Kent,
>          I think one possible way to handle this issue is to determine pixel component type and pixel type by input a PixelType value in ImageIOBase::SetPixelTypeInfo() but not type_info. 
> I upload 4 patches to demonstrate how could it work. 
> 
> 
> 
> 
> 
> 
> 
> kind regards
> 
> 
> 
> wanlin
> 
> 
> 
> On Fri, Nov 12, 2010 at 6:28 AM, kent williams <norman-k-williams at uiowa.edu> wrote:
> Currently, itkImageIOBase contains what many people would regard as a
> terrible offense against the commandments of Generic Programming:
> 
> bool ImageIOBase::SetPixelTypeInfo(const std::type_info &ptype);
> 
> This function is called with the type_info for the pixel type from
> itk::ImageFileWriter.
> 
> The problem is described here:
> http://public.kitware.com/Bug/view.php?id=11426
> 
> where the complaint is that ImageIO can't write images with vector pixels
> longer than 7 elements.  The reason this is the case is that there's a long
> if/then/else chain that compares the ptype to the typeid of a set of
> explicitly named types, and no one, so far, had added vectors of length > 7
> elements.
> 
> This would be a great place to do some Template MetaProgramming, but it's
> complicated.  Given the ImageType::PixelType one has to discriminate the
> PixelType (e.g. scalar,rgb,vector,covariantvector, complex), the number of
> components, and the component type.
> 
> I'm feeling overwhelmed trying to sort this one out; I'm submitting a topic
> to gerrit that just punts -- i.e. I increase the possible vector size
> supported without re-organizing and template-izing things.
> 
> Anyone want to give it a go?
> 
> _______________________________________________
> 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
> 
> <itkImageIOBase.h.patch><itkImageIOBase.cxx.patch><itkImageFileWriter.txx.patch><itkRawImageIO.txx.patch><ATT00001..txt>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/mailman/private/insight-developers/attachments/20101112/2d4cc8f7/attachment.htm>


More information about the Insight-developers mailing list