Apply colormap to 10 and 12 bit data without losing precision

Hello OpenCV Community,

I’m currently working on a project where I’m dealing with raw images of various bit depths - specifically 8, 10, and 12-bit images. My primary requirement is to apply a color map to these images. The key challenge I’m facing is how to apply the color map without losing any precision in the pixel intensity values.

As you may know, OpenCV’s applyColorMap function is designed for 8-bit images. When dealing with higher bit depth images (10-bit or 12-bit), directly applying a color map isn’t straightforward as it requires converting these images to 8-bit, potentially leading to loss of precision.

The images I’m working with are purely for intensity analysis, where every bit of data is crucial. Therefore, any loss of precision is undesirable. Is there a way to apply a color map to these higher bit depth images while maintaining their original precision? I’m looking for a method or a workaround that allows me to visualize these images in color without compromising the raw intensity data.

Any suggestions, advice, or guidance on how to approach this would be greatly appreciated.

Thank you in advance for your help!