My goal is to remove shadows from the image. I use C ++ and OpenCV. I am sure I lack a mathematical background, and I am not a native speaker of English, which is becoming increasingly difficult to understand.
After reading through various approaches to removing shadows, I found a method that should work for me, but it relies on what they call โ 2D color โ and โ 2D color space of a magazine โ but even this term seems inconsistent in different sources. Many related articles, few are listed here:
http://www.cs.cmu.edu/~efros/courses/LBMV09/Papers/finlayson-eccv-04.pdf http://www2.cmp.uea.ac.uk/Research/compvis/Papers/DrewFinHor_ICCV03. pdf http://www.cvc.uab.es/adas/publications/alvarez_2008.pdf http://ivrgwww.epfl.ch/alumni/fredemba/papers/FFICPR06.pdf
I inflated Google into strips, trying to find the right words and explanations. The best I found was the Illinination invant image , which didn't help me much.
I tried to repeat the formula journal (G / R), the journal (B / R) described in the first article, on page 3, to get numbers similar to 2b.

As input, I used http://en.wikipedia.org/wiki/File:Gretag-Macbeth_ColorChecker.jpg
The output I get is 
My source code:
#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);
}
What I donโt understand or misunderstand?