Gray16Lib is a library to provide various grayscale image processing algorithms to down-convert 16-bit grayscale images to bit-depths that are viewable on standard displays and maintain image contrast.
16-bit grayscale imagery is commonly encountered in scientific fields. Two notable examples include X-Ray and Aerial imaging. Sensors may raster data such as light intensity, or elevation data, using a 16-bit value. Typical consumer displays are capable of displaying 24-bit color (8-bits per channel: Red/Green/Blue, with some supporting pseudo 10-bit, usually 8-bit + FRC (Frame Rate Control) - basically faking the extra depth by flashing a pixel between two colors). To view the 16-bits of data on a display capable of displaying on 8-bits, it becomes necessary to appropriately "throw away" pieces of data while still maintaining important image contrast or splitting the 16-bits across multiple channels of 8-bit data.
Gray16Demo is an example application that will load a 16-bit Grayscale PNG and allow the user to interactively explore different image processing algorithms. Open your own 16-bit PNGs or load an example from the Examples menu (see the included 16-bit examples here).
- Qt 6.2+
QImage::Format_Grayscale16
was added in Qt 5.13 (released June 19th, 2019). References: QTBUG-41176, Gerrit patch.
- Manual
- Manually select Black-Point and White-Point values.
- Offset / Gain
- Offset pixel values then bit-shift them. No floating point operations.
- Auto-Offset, Manual Gain
- Offset chosen by least-exposed pixel, that isn't zero-exposed.
- Offset (+ 255) chosen by most-exposed pixel, that isn't fully saturated.
- False-Color (conversion to RGB32)
- Converts a 16-bit grayscale to an RGB gradient. Supports various gradients.
- Black Body
git clone https://github.com/linville/gray16lib.git
cd gray16lib
mkdir build && cd build
cmake ..
make
- Add more algorithms.
- Add more examples.
- Mootz and Mathews. "Displaying and Stretching 16-bit per Band Digital Imagery." USDA FSA