team-charls / charls

CharLS, a C++ JPEG-LS library implementation
BSD 3-Clause "New" or "Revised" License
180 stars 74 forks source link

how to encode and decode an 20bitsdeep bmp? #284

Closed duzhizeng closed 9 months ago

vbaderks commented 10 months ago

CharLS includes a sample application that shows how to encode a 3 * 8 bits (24 bits) color .bmp file to JPEG-LS. Not sure what a 20 bits deep bmp is? Grayscale or Color?

duzhizeng commented 10 months ago

CharLS includes a sample application that shows how to encode a 3 * 8 bits (24 bits) color .bmp file to JPEG-LS. Not sure what a 20 bits deep bmp is? Grayscale or Color?

the image format is RAW-RGGB,each pixel has 12or 16 or 20bits

vbaderks commented 9 months ago

I am not familiar with the RAW-RGGB format. It seem to be a direct image of a sensor with a color filters in a typical pattern (source https://en.wikipedia.org/wiki/Bayer_filter), with a typical arrangement of:

G R G R G R.... B G B G B G G R G R G R B G B G B G

To encode this image the following steps could be used:

The problem is that there are more green pixels (in the height) then red or blue. Red and blue can be considered sub-sampled in this context. The JPEG-LS standard supports sup-sampling. This is however a feature that is not implemented by the current implementation of CharLS.

An alternative would to encode the whole image as grayscale, this would however give a bad compression ratio.