从openCV imread使图像更暗

时间:2014-10-14 18:46:54

标签: c++ image opencv

我使用的是openCV 2.4.9,我的图像有问题。

我有这个原始图像, enter image description here

在C ++中我做了,

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

通过imshow或imwrite,我总能得到以下图片,

enter image description here

所以你可以看到,它更暗,我不知道为什么会这样。我已尝试过imread中的所有标志但它也做同样的事情。有人可以帮忙吗?

感谢您的时间。我非常感谢你的帮助。

Wazhup

2 个答案:

答案 0 :(得分:4)

根据ImageMagick,它在sRGB色彩空间中,伽马值为0.4545。我怀疑这不是OpenCV所期望的,可能需要进行一些伽玛或色彩空间校正。对不起,我无法发布此评论(而非答案),因为它太大了,格式化将是荒谬的。希望它具有建设性,并有助于引导某人为您找到解决方案。

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

答案 1 :(得分:0)

使用GIMP打开文件后,图片似乎嵌入了ProPhoto颜色配置文件。 GIMP可以将颜色配置文件更改为正常的RGB,如下所示,使用OpenCV或Matlab将照常打开。

enter image description here

enter image description here