2010.12.06 23:27 "[Tiff] 16 bit gray scale conversion", by Jamie L. Finch

2010.12.06 23:40 "Re: [Tiff] 16 bit gray scale conversion", by Chris Cox

Different results in what application?

How exactly are they showing differently?

Are they confusing gamma encodings (normally applied to 16 bit/channel ints, but not to 32 bit/channel floats)?

Yes, normally the linear scaling you are doing should be just fine -- as long as gamma encoding has been resolve beforehand.

Chris

On 12/6/10 3:27 PM, "Jamie L. Finch" <wi6f@cruzio.com> wrote:

Dear Tiff Group,

I was assigned a bug in LightWaves bump mapping.

The complaint was that 16 bit tiffs do not show the same results as 32 bit tiffs.

I wanted to make sure that I am converting the tiffs to floating point correctly.

I am most interested in 16 bit PHOTOMETRIC_MINISBLACK, which is the else case. Can anyone confirm that the conversion from short to float is correct?

This conversion is before any color correction is applied.

Jamie Finch
NewTek, Inc.

                 /* Extract pixel values and send to LW... */

                 for( i = 0; i < Height; i++ ) {
                     TIFFReadScanline( tif, InBuf, i, 0 );

                     Sorc.SS = (short *) InBuf;
                     Dest.FP = (float *) IndexLine;
                     switch( BitsPerSample ) {

                         /* Grayscale. */

                         case 16:
                             if( Photometric == PHOTOMETRIC_MINISWHITE )
{ /* Gotta reverse values. */
                                 for( j = 0; j < Width; j++ )
                                     *Dest.FP++ = ( 65535.0F - (float)
*Sorc.US++ ) / 65535.0F;
                                 }
                             else {
                                 for( j = 0; j < Width; j++ )
                                     *Dest.FP++ = ( (float) *Sorc.US++ )
/ 65535.0F;
                                 }
                             break;

                         /* Grayscale. */

                         case 32:
                             if( Photometric == PHOTOMETRIC_MINISWHITE )
{ /* Gotta reverse values. */
                                 for( j = 0; j < Width; j++ )
                                     *Dest.FP++ = 1.0F - *Sorc.FP++;
                                 }
                             else {
                                 for( j = 0; j < Width; j++ )
                                     *Dest.FP++ = *Sorc.FP++;
                                 }
                             break;
                         }
                     if( LWIP_SENDLINE( ip, i, IndexLine ) != 0 )
                         break;
                     }