Add new comment

LibRaw / C++ Undebayered Buffer

Hi All,

I am using LibRaw to decode raw files from Cannon and Nikon DSLR cameras. My code example currently looks like this:

m_raw_proc = new LibRaw;
 
int ret;
 
m_raw_proc->imgdata.params.use_camera_wb = 1;
m_raw_proc->imgdata.params.output_bps = 16;
m_raw_proc->imgdata.params.output_color = 1;
m_raw_proc->imgdata.params.gamm[0] = 1;
m_raw_proc->imgdata.params.gamm[1] = 1;
m_raw_proc->imgdata.params.highlight = 0;
m_raw_proc->imgdata.params.no_auto_bright = 0;
m_raw_proc->imgdata.params.user_qual = 0;
 
if ((ret = m_raw_proc->open_buffer(data, size)) != 0)
{
     // Handle error
}
 
if ((ret = m_raw_proc->unpack() != 0))
{
    // Handle error
}
 
if ((ret = m_raw_proc->raw2image()) != 0)
{
    // Handle error
}
 
if ((ret = m_raw_proc->dcraw_process()) != 0)
{
	 // Handle error
}
 
buffer = new uint16_t[m_raw_proc->imgdata.sizes.iwidth * m_raw_proc->imgdata.sizes.iheight * 3 + 3];
 
m_Width = m_raw_proc->imgdata.sizes.iwidth;
m_Height = m_raw_proc->imgdata.sizes.iheight;
 
for (int n = 0, m = 0; n < m_Width * m_Height; n++, m += 3)
{
	buffer[m] = m_raw_proc->imgdata.image[n][0];
	buffer[m + 1] = m_raw_proc->imgdata.image[n][1];
	buffer[m + 2] = m_raw_proc->imgdata.image[n][2];
}

The code example above creates RGB image data contained in buffer[] and works perfectly. That is, I can save buffer[] with something like libtiff.

However, the files from high-resolution DSLR cameras produce huge RGB files (especially in 16-bit). I would therefore like to create a data buffer which contains undebayered data which I could then debayer at a later stage (for example, during post-processing). Is this possible with LibRaw? My ultimate aim is to reduce the size of the output without using compression.

Many thanks
Amanda

Forums: