[Insight-users] 16-bit -> 8-bit pixels

Gib Bogle g.bogle at auckland.ac.nz
Wed Sep 14 00:55:42 EDT 2011


Thanks Bill,

It turns out that what I knew was not the case.  I was fooled by the way 
Irfanview reports image info.  In fact the files I've examined so far have a max 
value of 4096, i.e. they are using 12 bits, stored in 16 bits.  There's probably 
a much easier way, but I've written code to read each file and write the 
converted values into an 8-bit 3D image.

Cheers
Gib

On 14/09/2011 3:37 p.m., Bill Lorensen wrote:
> When you declare your image series reader use unsigned char as the type. The 
> reader will produce the output type regardless of the actual type in the files 
> themselves. It does so with a simple cast. This can be dangerous, but in your 
> case, you know the values are less than 255.
>
> On Tue, Sep 13, 2011 at 11:29 PM, Gib Bogle <g.bogle at auckland.ac.nz 
> <mailto:g.bogle at auckland.ac.nz>> wrote:
>
>     I'm reading a set of 2D tiff images and writing a 3D tiff (essentially the
>     example IO/ImageSeriesReadWrite.cxx).  The 2D tiffs have 16-bit pixels,
>     but the pixel values are all less than 255.  I want the output file to be
>     8-bit.  How should I do the conversion (the example ImageReadCastWrite
>     uses RescaleIntensityImageFilter to convert between different pixel
>     formats, but I do not want to rescale the values).
>     _____________________________________
>     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://www.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-users
>
>


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110914/b8222461/attachment.htm>


More information about the Insight-users mailing list