Add new comment

If I have bayer data, how to process it to get the image?

I've a custom decompress code that decompresses a certain compressed RAW image into bayer monochrome 16-bit data. The actual bit depth of the sensor is 14-bit.

Now that I've the bayer data, how do I use LibRaw to turn it into a useable image?

My code currently looks like this:

raw->imgdata.rawdata.raw_image = (ushort *)bayer_data;
raw->imgdata.sizes.raw_width = width;
raw->imgdata.sizes.raw_height = height;
raw->imgdata.sizes.width = width;
raw->imgdata.sizes.height = height;
raw->imgdata.idata.filters = 0x94949494; // Bayer pattern (adjust according to your camera)
raw->imgdata.idata.colors = 3;
raw->imgdata.idata.cdesc[0] = 'R';
raw->imgdata.idata.cdesc[1] = 'G';
raw->imgdata.idata.cdesc[2] = 'B';

// Set additional parameters
raw->imgdata.idata.raw_count = 1;
raw->imgdata.idata.is_foveon = 0;
raw->imgdata.idata.colors = 3;
raw->imgdata.idata.filters = 0x94949494; // Bayer pattern (adjust according to your camera)
raw->imgdata.idata.cdesc[0] = 'R';
raw->imgdata.idata.cdesc[1] = 'G';
raw->imgdata.idata.cdesc[2] = 'B';

// Set the LibRaw options
raw->imgdata.params.output_bps = 16;
raw->imgdata.params.no_auto_bright = 1;
raw->imgdata.params.use_auto_wb = 1; // Enable automatic white balance
raw->imgdata.params.green_matching = 1; // Ensure green matching is enabled

// Unpack and demosaic the data
rc = raw->unpack();

After calling unpack(), I got error of -4, "Out of order call of libraw function".

I looked at the unpack source code, it seems imgdata.rawdata.raw_image is reset to 0.

So how can I pass bayer data to LibRaw?

Forums: