Re: Saving three 16 bit RGB values in 32 bits::
- From: davem@xxxxxxxxx (Dave Martindale)
- Date: Sat, 10 Sep 2005 07:16:28 +0000 (UTC)
Wenny Macura <wmacu@xxxxxxxxx> writes:
>I have been fiddling with large 16 bit images for a while.
>and have been trying to save the image allocation space on the disk.
>Since the image RGB values are independent of each other
>and the individual color component values are in the range of 0 to 65535,
>they can be stored as a single 32 bit floating point number.
No, you need at least 47 bits of mantissa to store three arbitrary
16-bit values. (47 instead of 48 because of the free "hidden bit" in
IEEE floating point representation). And that's using the optimum scale
factor of 65536, not 100000.
> * double Utility::RGB_ToDBL( int R, int G, int B)
Your code *should* work, but it's storing the values in a double which
is 64 bits total, with something like 51 or 52 bits of mantissa
precision. But note that sizeof(double) == 8, which is 2 more bytes
than you started with.
Try recompiling your code using "float" instead of "double". Test it
and see whether you get any useful blue bits back at all.
Dave
.
- References:
- Saving three 16 bit RGB values in 32 bits::
- From: Wenny Macura
- Saving three 16 bit RGB values in 32 bits::
- Prev by Date: Re: Saving three 16 bit RGB values in 32 bits::
- Next by Date: Re: Suggest a challenging research idea
- Previous by thread: Re: Saving three 16 bit RGB values in 32 bits::
- Next by thread: handwritten digit library by JOONE and ImageJ
- Index(es):