如何计算2D对数色度? [英] How to compute 2D log-chromaticity?

查看:211
本文介绍了如何计算2D对数色度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目标是去除图像上的阴影.我使用C ++和OpenCV.当然,我缺乏足够的数学背景,而且不会以英语为母语的人很难理解所有内容.

My goal is to remove shadows from image. I use C++ and OpenCV. Sure I lack enough math background and not being native English speaker makes everything harder to understand.

在阅读了不同的去除阴影的方法之后,我发现了应该适合我的方法,但是它依赖于他们称为" 2D色度"和" 2D对数色度空间"的东西. ",但即使在不同的消息来源中,这个术语似乎也不一致.关于该主题的论文很多,这里列出的论文很少:

After reading different approaches to remove shadows I found method which should work for me but it relies on something they call "2D chromaticity" and "2D log-chromaticity space" but even this term seems to be inconsistent in different sources. Many papers on topic, few are listed here:

http://www. cs.cmu.edu/~efros/courses/LBMV09/Papers/finlayson-eccv-04.pdf http://www2.cmp.uea.ac.uk/研究/compvis/Papers/DrewFinHor_ICCV03.pdf http://www.cvc.uab.es/adas/publications/alvarez_2008. pdf http://ivrgwww.epfl.ch/alumni/fredemba/papers/FFICPR06. pdf

我通过搜索正确的单词和解释将Google撕成碎片.我发现最好的是照明不变图像,对我没有多大帮助.

I teared Google into strips by searching right words and explanations. Best I found is Illumination invariant image which did not help me much.

我试图重复第一篇论文第3页中描述的公式 log(G/R) log(B/R),以获得类似于2b的数字.

I tried to repeat formula log(G/R), log(B/R) described in first paper, page 3 to get figures similar to 2b.

作为输入,我使用了 http://en.wikipedia.org/wiki /File:Gretag-Macbeth_ColorChecker.jpg

我得到的输出是

我的源代码:

#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <iostream>
#include <stdio.h>

using namespace std;
using namespace cv;

int main( int argc, char** argv ) {
  Mat src;

  src = imread( argv[1], 1 );

  if( !src.data )
    { return -1; }

  Mat image( 600, 600, CV_8UC3, Scalar(127,127,127) );

  int cn = src.channels();
  uint8_t* pixelPtr = (uint8_t*)src.data;

  for(int i=0 ; i< src.rows;i++) {
      for(int j=0 ; j< src.cols;j++) {
          Scalar_<uint8_t> bgrPixel;
          bgrPixel.val[0] = pixelPtr[i*src.cols*cn + j*cn + 0]; // B
          bgrPixel.val[1] = pixelPtr[i*src.cols*cn + j*cn + 1]; // G
          bgrPixel.val[2] = pixelPtr[i*src.cols*cn + j*cn + 2]; // R
          if(bgrPixel.val[2] !=0 ) { // avoid division by zero
              float a= image.cols/2+50*(log((float)bgrPixel.val[0] / (float)bgrPixel.val[2])) ;
              float b= image.rows/2+50*(log((float)bgrPixel.val[1] / (float)bgrPixel.val[2])) ;
              if(!isinf(a) && !isinf(b))
                  image.at<Vec3b>(a,b)=Vec3b(255,2,3);
          }
      }
  }

  imshow("log-chroma", image );
  imwrite("log-chroma.png", image );
  waitKey(0);

}

我缺少或误解了什么?

推荐答案

通过阅读论文通过发布的照明不变性从阴影中去除了色度的图像以及您的代码,我想问题是您的坐标系(X/Y轴)是线性的,而在本文中,坐标系是log(R/G)乘log(B/G).

By reading the paper Recovery of Chromaticity Image Free from Shadows via Illumination Invariance that you've posted, and your code, I guess the problem is that your coordinate system (X/Y axis) are linear while in the paper the coordinate system are log(R/G) by log(B/G).

这篇关于如何计算2D对数色度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆