Raw 12 to raw 8 bit

Hello everyone,

I’m using a CSI Camera that outputs 12 bit RAW stream. Whats the best possible way where I can convert that to 8 bit RAW? Chopping off 4 bits is not a option as we use IR light to illuminate as its a high power LED so I want to extract as much information from Camera.
Any suggestions are welcome.

Thanks

1 Like

Hello Gurpreet -

How do you judge “as much information,” and how would you
determine whether a proposed method were better than the
simple approach of truncating the lowest four of your twelve
bits?

If I were to give you two 12-to-8-bit converters, how, in very
concrete terms, would you decide which was better?

(The question you are asking has the potential to be quite
complicated, or, perhaps, rather simple.)

Thanks, mm

1 Like

Hello @mountain_man.

Well I capture multiple images and combine them using HDR. Currently it works fine if I simply scale down to 8(there is opencv function to do that) bit but sometimes information in lost in high sunlight conditions, that’s why I was asking about better strategy. I’m not expert on image processing, so simply wanna hear new ideas and maybe anyone can guide me through a good resource on this.

Hello Gurpreet -

It sounds like you are looking for contrast enhancement and
grayscale quantization. One good approach to grayscale
quantization is histogram equalization.

In Fiji / ImageJ, you could read in your 12-bit image as a 16-bit
image. Then run:

Process > Enhance Contrast...

checking the “Equalize histogram” checkbox.

Then convert your image to 8-bit by running:

Image > Type > 8-bit

Thanks, mm

Thanks @mountain_man for pointing me to right direction. Just a other question how does image display 16 bit images on 8 bit monitors?

Gurpreet

By using a lookup table: pick the actual minimum and maximum value and stretch this so 0 is the darkest and 255 is the brightest value?
Of course, if you have specific requirements you can adapt that strategy. If the information is in the lower bits and you do have aquired 16-bit images, you act differently than when the information is in the upper bits. Dynamic range is the keyword here.

Hello there, and welcome.
Personally I always convert most things to 32bit as a start. It provides the greatest flexibility for any downstream processing. You can always downsize but you cannot upsize without losing data.
Bob

Sounds as if what the original poster wants is tone mapping:

Note that the original question cannot be answered as converting from 12 bit RAW to 8 bit RAW is not possible by definition if one considers RAW to mean “as it comes out of the camera”.