-
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 13:19 "Re: How to interpret 16-bit GrayScale image?", by Martí Maria
- 2002.01.21 10:47 "Re: How to interpret 16-bit GrayScale image?", by Bad Badtz
- 2002.01.21 17:23 "Re: How to interpret 16-bit GrayScale image?", by Daniel McCoy
-
2002.01.21 03:06 "RE: How to interpret 16-bit GrayScale image?", by Bad Badtz
- 2002.01.16 16:12 "Re: How to interpret 16-bit GrayScale image?", by Martí Maria
- 2002.01.24 01:47 "Re: How to interpret 16-bit GrayScale image?", by Bad Badtz
2002.01.21 23:26 "Re: How to interpret 16-bit GrayScale image?", by Martí 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----