AWARE [SYSTEMS]
AWare Systems, , Home TIFF and LibTiff Mailing List Archive

LibTiff Mailing List

TIFF and LibTiff Mailing List Archive
December 2010

Previous Thread
Next Thread

Previous by Thread
Next by Thread

Previous by Date
Next by Date

Contact

The TIFF Mailing List Homepage
Archive maintained by AWare Systems



New Datamatrix section



Valid HTML 4.01!



Thread

2010.12.06 23:27 "16 bit gray scale conversion", by Jamie L Finch
2010.12.06 23:40 "Re: 16 bit gray scale conversion", by Chris Cox

2010.12.06 23:27 "16 bit gray scale conversion", by Jamie L Finch

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;
                     }