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

kent williams norman-k-williams at uiowa.edu
Fri Nov 12 08:32:42 EST 2010


Thanks! I actually figured this out last night ‹ a solution almost identical
to yours. Only difference is that instead of a pixel instance type, e.g.

SetPixelTypeInfo(const TPixel *) { /* set pixel stuff */ }

And then call it 

SetPixelTypeInfo(static_cast<const TPixel *>(0));

On 11/12/10 2:13 AM, "wanlin" <wanlinzhu at gmail.com> 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 <http://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
> 
> 

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


More information about the Insight-developers mailing list