Add new comment

Some questions to better understand the available data when opening a raw file with libraw

Hey folks,

last semester I did a nice seminar about image processing and somehow the demosaicing algorithms got me. So I'm now experimenting with different demosaicing and image processing algorithms and recently started to implement some testcode using libraw for reading DSLR photos. Now I have a few questions to better understand what's happening where the documentation didn't help or maybe I didn't understood it well.

1.) When handling data from a CFA sensor after unpacking raw_image points to an array with raw_height*raw_width as a 1D array? And this data is the untouched data contained in the file? Only raw2data does stuff like black point correction, right? And does the raw_image buffer contain the full “raw” sized image or is it already cropped to the usable pixel area? Is it safe to use a few of the pixels just outside the officially usable pixel area as a base for the demosaicing code (outside pixel used for the interpolation of the pixels on the edges)?

2.) Is the curve in libraw_colordata always populated if the raw is not linear or are there files where a formula to calculate to linear is somehow offered? Is it always fully populated? I wonder about the size of 0x4001 which seems a bit odd to me. Or is there some information about the size somewhere? I assume this LUT will also scale black and white level? Or am I wrong here? I want to have all raw data normalised to a 0.0-1.0 range for my algorithms so I search for the best way to achieve this manually (see comment after point 3.).

3.) How can I get the raw pixel order? I get that imgdata.idata.cdesc contains RGBG if it is a RGB CFA but how can I know if the first line is GR, RG, GB or BG?

My code is doing raw processing on the GPU where I also want to do all the necessary pre-processing to save some cpu time on mass processing as I will do all the image processing in the GPU anyways so that’s why I want to do as few of the tasks in libraw as possible just copying the raw_image to the GPU and go from there. Currently I hacked around libraw until I got some usable data to my debayering code implemented in CUDA but I’d like to improve my code a bit now and have a way that not only works for my specific 5DmkIII cr2 files.

PS: Sorry if I missed some stuff while browsing through the forum or the documentation but as I read in a few forum threads the documentation is also not up to all changed stuff of the most current libraw versions so I thought I’d better ask about the stuff that is still unclear.

Forums: