2
votes

I'm using openCV 2.4.9 and I have a problem with images.

I have this original imagem, enter image description here

In C++ I do,

cv::Mat img = cv::imread(sourceImgPath, CV_LOAD_IMAGE_UNCHANGED);
imshow("test", img); //or imwrite(path, img);

And with imshow or imwrite I get always the following image,

enter image description here

So as you can see, it's darker and I have no idea why this happen. I have tried all the flags from imread but it does the same thing. Anyone can help?

Thanks for your time. I really appreciate your help.

Wazhup

2

2 Answers

4
votes

According to ImageMagick it is in sRGB colourspace with a gamma of 0.4545. I suspect that is not what OpenCV is expecting and some gamma or colourspace correction is maybe required. Sorry, I could not post this as a comment (rather than an answer) because it is too big and the formatting would be ridiculous. Hopefully it is constructive and will help lead someone to a solution for you.

Image: brDaP.jpg
  Format: JPEG (Joint Photographic Experts Group JFIF format)
  Mime type: image/jpeg
  Class: DirectClass
  Geometry: 600x400+0+0
  Units: Undefined
  Type: TrueColor
  Endianess: Undefined
  Colorspace: sRGB
  Depth: 8-bit
  Channel depth:
    red: 8-bit
    green: 8-bit
    blue: 8-bit
  Channel statistics:
    Pixels: 240000
    Red:
      min: 0 (0)
      max: 255 (1)
      mean: 100.628 (0.39462)
      standard deviation: 52.5382 (0.206032)
      kurtosis: 0.337274
      skewness: 0.482249
    Green:
      min: 0 (0)
      max: 255 (1)
      mean: 108.882 (0.426989)
      standard deviation: 55.0518 (0.215889)
      kurtosis: -0.330334
      skewness: 0.193815
    Blue:
      min: 0 (0)
      max: 255 (1)
      mean: 128.997 (0.505872)
      standard deviation: 70.9162 (0.278103)
      kurtosis: -1.38343
      skewness: -0.0647535
  Image statistics:
    Overall:
      min: 0 (0)
      max: 255 (1)
      mean: 112.836 (0.442493)
      standard deviation: 60.0557 (0.235513)
      kurtosis: -0.536439
      skewness: 0.289801
  Rendering intent: Perceptual
  Gamma: 0.454545                      <--------------------- GAMMA
  Chromaticity:
    red primary: (0.64,0.33)
    green primary: (0.3,0.6)
    blue primary: (0.15,0.06)
    white point: (0.3127,0.329)
  Background color: white
  Border color: srgb(223,223,223)
  Matte color: grey74
  Transparent color: black
  Interlace: None
  Intensity: Undefined
  Compose: Over
  Page geometry: 600x400+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: JPEG
  Quality: 99
  Orientation: Undefined
  Properties:
    date:create: 2014-10-14T22:03:59+01:00
    date:modify: 2014-10-14T22:03:59+01:00
    icc:copyright: Copyright (c) Eastman Kodak Company, 1999, all rights reserved.
    icc:description: ProPhoto RGB
    icc:manufacturer: KODAK
    icc:model: Reference Output Medium Metric(ROMM)  
    jpeg:colorspace: 2
    jpeg:sampling-factor: 1x1,1x1,1x1
    signature: c436a68fe624fd471fcd3563b7dafa154ec4f17e784a448a2863a24856c70be6
  Profiles:
    Profile-icc: 940 bytes
  Artifacts:
    filename: brDaP.jpg
    verbose: true
  Tainted: False
  Filesize: 210KB
  Number pixels: 240K
  Pixels per second: 24MB
  User time: 0.000u
  Elapsed time: 0:01.009
  Version: ImageMagick 6.8.9-7 Q16 x86_64 2014-09-10 http://www.imagemagick.org
0
votes

After opening the file with GIMP, it seems the image has a ProPhoto embedded color profile. GIMP can change the color profile into a normal RGB like the one below, which will be opened as usual using OpenCV or Matlab.

enter image description here

enter image description here