Add new comment

Visible Pixels

Further to my original post.

My code works for Nikon DSLR cameras via imgdata.rawdata (albeit the images seem to be under-exposed) but images from Canon DSLRs are showing bad data near the top of each image. I've been reading various forum posts and it seems that I need to call raw2image() in order to get data that only contains visible (active pixels) pixels but I am struggling to get unbayered data.

It is my understanding that after calling raw2image() and without calling dcraw_process() I should have an undebayered dataset in imgdata.image[][] which only contains visible pixels, is that correct?

What I need to do is to copy data from imgdata.image[][] to a one dimensional 16-bit integer array (size is width * height) that gets saved as a FITS or a TIFF file which can then be debayered later by my post-processing application.

Here is a code example of what I am currently doing:

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
}
 
m_width = m_raw_proc->imgdata.sizes.iwidth;
m_height = m_raw_proc->imgdata.sizes.iheight;
 
for (int n = 0; n < m_width * m_height; n++)
{
	buffer[n] = m_raw_proc->imgdata.image[n][0];
}

However, when I try to debayer the image in an external application, the code above is heavily bias to a specific primary colour. How do I correctly access the undebayered data from imgdata.image[][]?

Thanks
Amanda