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

kent williams norman-k-williams at uiowa.edu
Thu Nov 11 14:28:30 EST 2010


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?



More information about the Insight-developers mailing list