How to calculate 2D color log?

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.

enter image description here

As input, I used http://en.wikipedia.org/wiki/File:Gretag-Macbeth_ColorChecker.jpg

The output I get is log-chromacity

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?

+6
source share
2 answers

After reading the article Restoring chromaticity images without shadows using the lighting invariance that you indicated, and your code, I think the problem is that your coordinate system (X / Y axis) is linear, and in the document the coordinate system is log (R / G) by log (B / G).

+1
source

This is the closest I can understand. After reading this:

http://www2.cmp.uea.ac.uk/Research/compvis/Papers/DrewFinHor_ICCV03.pdf

I met a suggestion:

โ€œFigure 2 (a) shows the logarithmic colors for the 24 surfaces of the ColorBacker Macbeth diagram, ( six neutral patches belong to the same cluster ). If we now change the values and median plot values โ€‹โ€‹for each patch , we see the curves in Figure 2 (b) . "

If you look closely at the log history chart, you will see 19 drops corresponding to each of the 18 colors in the Macbeth chart, plus the sum of all 6 gray in the bottom line:

Journal History Explanation

Journal History Explanation

With 1 image, we can only get 1 byte of each block: we take the median value inside each target and borrow it. To get a plot out of paper, we would have to create several images with different lighting. We could do this by changing the temperature of the image in the image editor.

For now, I just looked at the color patches in the original image and plotted the dots:

Input:

Used color patches

Output:

Chroma Magazine

Graphic dots are not all in one place with paper, but I find it pretty close. Anyone please check my work to make sure this makes sense?

0
source

All Articles