DNG to RGB Converter

This function converts RAW image images file to RGB (Truecolor) Images. It follows Rob Sumner's "Processing RAW Images in MATLAB" guide
Updated 30 Apr 2019

View License

Commercial Grade Digital cameras incorporate built-in image processing software that makes photographs look aesthetically pleasing to the human eye, but and introduce non-linearities and compression artifacts that hinder their use as scientific instruments. However, their image sensor originally produce linear outputs. Access to this linear data requires specific image processing which is detailed in this function.

Here we follow Rob Sumner's (2014) "Processing RAW Images in MATLAB" guide. The full document can be found here: http://www.rcsumner.net/raw_guide/RAWguide.pdf

Our implementation of the guide mimics the following workflow (that happens under-the-hood within the camera's built-in software). The function outputs all the intermediate image steps, including the original raw file and the camera settings.

[lin_srgb, lin_rgb, balanced_bayer, lin_bayer, raw, camSettings] = dng2rgb(imagename)

- imagename [string] = Original raw (DNG) file name (e.g. 'DSC_0001.dng')

- lin_srgb [nxmx3 double][0-1] = 16-bit, RGB image that has color corrected and exists in the right color space
- lin_rgb [nxmx3 double][0-1] = RGB image from balanced_bayer using demosaic()
- balanced_bayer [nxm double] [0-1] = White Balanced-linearized raw data (Bayer array)
- lin_bayer [nxm double] [0-1] = Linearized raw data with black level and saturation level corrected
- raw [nxm double] [0-1] = Raw data (Bayer array) from the camera's sensor
- camSettings [structure] = Contains camera settings used for convertion from RAW -> lin_srgb

Cite As

Rafael Villamor Lora (2024). DNG to RGB Converter (https://www.mathworks.com/matlabcentral/fileexchange/71420-dng-to-rgb-converter), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2019a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes