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
Rafael Villamor Lora (2020). DNG to RGB Converter (https://www.mathworks.com/matlabcentral/fileexchange/71420-dng-to-rgb-converter), MATLAB Central File Exchange. Retrieved .
The black level is not consistent with the value read by the dcraw, so the color of the output image is not totally correct. Second, I have a problem when applying the code with the data set: https://www.kaggle.com/knn165897/s7-isp-dataset, this code doesn't work well, the color is inconsistent with the one from dcraw
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!