Retinex Color Restoration

asked 2019-05-08 13:26:38 -0600

hua gravatar image

I want to restore the colour of MSR(Multi-scale Retinex) using the following equation.

MSRCR(x, y) = G [C(x,y)*MSR(x, y) - b]

I tried to implement from this paper . 1: http://www.ipol.im/pub/art/2014/107/a...

//Colour Restoration Steps
Mat msrcrB, msrcrG, msrcrR;
multiply(crb, msrb, msrcrB); // For Blue Channel // crb, crg, crr are color restoration functions
multiply(crg, msrg, msrcrG); // For Green Channel
multiply(crr, msrr, msrcrR); // For Red Channel

msrcrB = (msrcrB + b); // G/O blue channel
msrcrG = (msrcrG + b); // G/O green channel
msrcrR = (msrcrR + b); // G/O red channel
msrcrB = G * msrcrB ; // G/O blue channel
msrcrG = G * msrcrG ; // G/O green channel
msrcrR = G * msrcrR ; // G/O red channel

minMaxLoc(msrcrB, &minb, &maxb);
minMaxLoc(msrcrG, &ming, &maxg);
minMaxLoc(msrcrR, &minr, &maxr);

Mat NORMmsrcrB, NORMmsrcrG, NORMmsrcrR;
normalize(msrcrB, NORMmsrcrB, 255, 0, NORM_MINMAX);
normalize(msrcrG, NORMmsrcrG, 255, 0, NORM_MINMAX);
normalize(msrcrR, NORMmsrcrR, 255, 0, NORM_MINMAX);

Mat msrcrCh[3] = { NORMmsrcrB, NORMmsrcrG, NORMmsrcrR };
Mat MSRCR;
merge(msrcrCh, 3, MSRCR);
convertScaleAbs(MSRCR, MSRCR);
namedWindow("MSRCR", WINDOW_FREERATIO);
imshow("MSRCR", MSRCR);
waitKey(0);

I want to get the final color restoration image. But I got a nonlinear output image.

MSR image and MSRCR image

In the above image, the MSR image correct and the MSRCR image is not correct.

edit retag flag offensive close merge delete

Comments

what is the type / range of crb,msrb ?

berak gravatar imageberak ( 2019-05-09 06:30:21 -0600 )edit

Both crb, msrb are CV_64FC1, sir. Following are the output from the program, sir.

msrb depth, no. of channels, and type: 6, 1, and 6
crb depth, no. of channels, and type: 6, 1, and 6
hua gravatar imagehua ( 2019-05-09 07:29:21 -0600 )edit