AWARE [SYSTEMS] Imaging expertise for the Delphi developer
AWare Systems, Imaging expertise for the Delphi developer, Home TIFF and LibTiff Mailing List Archive

LibTiff Mailing List

TIFF and LibTiff Mailing List Archive
January 2002

Previous Thread
Next Thread

Previous by Thread
Next by Thread

Previous by Date
Next by Date

Contact

The TIFF Mailing List Homepage
This list is run by Frank Warmerdam
Archive maintained by AWare Systems



Valid HTML 4.01!



Thread

2002.01.16 11:07 "How to interpret 16-bit GrayScale image?", by Bad Badtz
2002.01.16 12:52 "Re: How to interpret 16-bit GrayScale image?", by Marti Maria
2002.01.16 14:52 "Re: How to interpret 16-bit GrayScale image?", by Paul Beaty
2002.01.21 03:06 "Re: How to interpret 16-bit GrayScale image?", by Bad Badtz
2002.01.21 05:21 "Re: How to interpret 16-bit GrayScale image?", by Peter Montgomery
2002.01.21 09:59 "Re: How to interpret 16-bit GrayScale image?", by Marti Maria
2002.01.21 10:47 "Re: How to interpret 16-bit GrayScale image?", by Bad Badtz
2002.01.21 15:53 "Re: How to interpret 16-bit GrayScale image?", by Marti Maria
2002.01.21 15:24 "Re: How to interpret 16-bit GrayScale image?", by Michael Dechaine
2002.01.21 16:33 "Re: How to interpret 16-bit GrayScale image?", by Bob Friesenhahn
2002.01.21 17:23 "Re: How to interpret 16-bit GrayScale image?", by Daniel Mccoy
2002.01.21 23:06 "Re: How to interpret 16-bit GrayScale image?", by Marti Maria
2002.01.21 23:57 "Re: How to interpret 16-bit GrayScale image?", by Daniel Mccoy
2002.01.23 04:18 "Re: How to interpret 16-bit GrayScale image?", by Kevin D Quitt
2002.01.24 01:47 "Re: How to interpret 16-bit GrayScale image?", by Bad Badtz
2002.01.24 05:07 "Re: How to interpret 16-bit GrayScale image?", by Kevin D Quitt
2002.01.25 14:27 "Re: How to interpret 16-bit GrayScale image?", by Thomas Kumlehn

2002.01.21 23:06 "Re: How to interpret 16-bit GrayScale image?", by Marti Maria

Hi,

Don't trust blindly in me, just see by yourself. :-)

Here is a small program to acotate the induced error by the
256 method ( << 8 for expanding to 16 bits, >> 8 to convert
to 8 bits) and the 257 method (multiply and divide by 257).

To check error, I sweep from 0 to 0xFFFF, quantizing to
8 bits and then restoring back to 16 bits. The result is next
compared to original value and the error is computed as
abs(quantized - original). I avoided stnadar deviation and
further stadistics since seems clear we want peek error
only.

Using 257 method, you got a maximum error of 128, that is
almost half 8-bit value. Using << 8 you got 255, that is almost
one 8 bit value.

> FEFD / 101 = FD     are you sure you want this?

Yep, you have not done the neccessary rounding!:

FEFD / 101 = 253.996, rounding 254 = 0xFE

Just to make sense: 0x33FF is obviously more close to 0x34
tha 0x33.

Regards,
Mati.

------ cut -----

#include <stdio.h>
#include <stdlib.h>

int main()
{
 int i;
   unsigned char a8_by256, a8_by257;
   unsigned short a16_by256, a16_by257;
   int error256, error257;
   int max256 = 0, max257 = 0;

 for (i=0; i < 0xFFFF; i++) {

    a8_by256 = (unsigned char) (i >> 8);
      a8_by257 = (unsigned char) (double) (i / 257. + .5);

      a16_by256 = ((unsigned short) a8_by256 << 8);
      a16_by257 = ((unsigned short) a8_by257 << 8) | a8_by257;

      error256 = abs(a16_by256 - i);
      error257 = abs(a16_by257 - i);

      if (error256 > max256) max256 = error256;
    if (error257 > max257) max257 = error257;
   }

   printf("Error (Max) by 256 = %d, by 257 = %d\n", max256, max257);
   return 0;
}
----- cut----