2002.09.18 17:53 "Reading 16bits from a gray scale image", by Steven Luke

2002.09.19 00:40 "Re: Reading 16bits from a gray scale image", by Martí Maria

I am displaying the image in 8bits so the final number needs to be only 8bits, that is why I shifted the pixels the opposite direction at the end. I am not sure if I am doing this step correct either. I was thinking of dividing by 257 but am unsure of the rounding process and think that this is probably just as good because it is easier.

The correct method would be to divide by 257 and then round:

    r = floor(c / 257.0 + 0.5)

However this is painfull slow. If you don't care about memory, you could use a table of 64K for speeding up... other options would be to use fixed point.

Anyway, for most usages a simple >> 8 is enough.

Regards,

Marti.