Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Libraw is making my images too bright compared to nikons own converter

Tags:

c++

opencv

libraw

It seems that nikons own tool and photoshop has the option to open the image as they was taken.

but using libraws dcraw processor I cant figure this out.

here is my implementation.

CV_EXPORTS_W int load_image(const char * path, cv::Mat & output)
{


    LibRaw RawProcessor;

    int ret;

#define imgD RawProcessor.imgdata

    imgD.params.use_camera_wb = 1;
    imgD.params.use_auto_wb = 0;

    if ((ret = RawProcessor.open_file(path)) != LIBRAW_SUCCESS)
    {
        fprintf(stderr, path, libraw_strerror(ret));
        return -1;
    }
    if ((ret = RawProcessor.unpack()) != LIBRAW_SUCCESS)
    {

        return -1;
    }

    int check = RawProcessor.dcraw_process();
    libraw_processed_image_t *image_ptr = RawProcessor.dcraw_make_mem_image(&check);
                
    output = cv::Mat(cv::Size(image_ptr->width, image_ptr->height), CV_8UC3, image_ptr->data, cv::Mat::AUTO_STEP);
    cv::cvtColor(output, output, 4);
}

Updated with an image to show what I am talking about: The images are being normalized somehow. If the original image contains a large area of light matrial the overall image becomes more dark. I want to be able to just read the raw image data and normalize or handle it my own way in opencv.

enter image description here

update

Based on comments I got the brightness adjusted but a problem now arize with the pixel color values, best seen here:

enter image description here

The image on the left is the result of libraw and the right one is viewnx. There seem to be some noise colors in the libraw image.

like image 204
Poul K. Sørensen Avatar asked Mar 12 '14 15:03

Poul K. Sørensen


1 Answers

raw data is stored in LibRaw::rawdata.raw_image[] array. These values are 'as RAW as possible' without black subtraction and/on de-bayer (demosaic) applied.

To access this data you need to call LibRaw::open_file() and LibRaw::unpack.

Also, you may exclude some steps from data processing on LibRaw::dcraw_process():

 imgdata.params.no_interpolation=1 disables demosaic
 imgdata.params.no_auto_scale=1 disables scaling from camera maximum to 64k
 imgdata.params.no_auto_bright=1 disables auto brighten
like image 52
Alex Tutubalin Avatar answered Nov 01 '22 09:11

Alex Tutubalin