When I upload an image to OpenCV, it is always darker than the original. What for?

So, I am uploading a .png file of color that was taken with iphone using cvLoadImage. And after it was uploaded, when I immediately show it on my X11 terminal, the image is certainly darker than the original png file.

I am currently using this to upload an image: IplImage * img3 = cvLoadImage ("bright.png", 1);

For the second parameter, I tried all of the following:

CV_LOAD_IMAGE_UNCHANGED

CV_LOAD_IMAGE_GRAYSCALE

CV_LOAD_IMAGE_COLOR

CV_LOAD_IMAGE_ANYDEPTH

CV_LOAD_IMAGE_ANYCOLOR

but none of them worked. Grayscale definitely made the image grayscale. But, as suggested by http://www.cognotics.com/opencv/docs/1.0/ref/opencvref_highgui.htm , even using CV_LOAD_IMAGE_ANYDEPTH | CV_LOAD_IMAGE_ANYCOLOR, in order to download the image as truthfully as possible, led to a darker image displayed in the terminal.

Does anyone have any ideas on how to properly display the original image?

Many thanks.

+3
source share
3 answers

Yes, OpenCV does not apply gamma correction.


// from: http://gegl.org/
// value: 0.0-1.0
static inline qreal
linear_to_gamma_2_2 (qreal value){
  if (value > 0.0030402477)
    return 1.055 * pow (value, (1.0/2.4)) - 0.055;
  return 12.92 * value;
}
// from: http://gegl.org/
static inline qreal
gamma_2_2_to_linear (qreal value){
  if (value > 0.03928)
    return pow ((value + 0.055) / 1.055, 2.4);
  return value / 12.92;
}

+4
source

Does this only happen when loading into OpenCV? Does opening with any other viewer show a difference?

, , iPhone 1,8 (: http://www.colorwiki.com/wiki/Color_on_iPhone#The_iPhone.27s_Display). , X11 2,2 ( ).

, , X11, iPhone. , .

Edit:

, OpenCV -. :

http://permalink.gmane.org/gmane.comp.lib.opencv.devel/837

, "" ImageMagick. , :

http://www.4p8.com/eric.brasseur/gamma.html

+2

:

cvLoadImage("file.png", CV_LOAD_IMAGE_UNCHANGED);

One interesting test that you could do to determine if OpenCV is really messing with image data, just creates another image using cvCreateImage (), then copy the data to this newly created image and save it in another cvLoadImage () file.

Perhaps this is just a display error. Of course, I suggest you upgrade to the latest version of OpenCV.

0
source

Source: https://habr.com/ru/post/1754785/


All Articles