I have an image which captures 8 bit. I'm looking to convert the 8 bit values to 16 bit. I used the following
short temp16 = (short)val[i] << 8 ;
where val
is an array of 8 bit samples.
The above statement makes noisy. Can anybody suggest a method for 8bit to 16bit conversion?
Pure bitshifting won't give you pure white. 0xff << 8 == 0xff00, not 0xffff as expected.
One trick is to use val[i] << 8 + val[i] and remember proper datatypes (size, signedness). That way you get 0x00 -> 0x0000 and 0xff -> 0xffff.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With