Retinex algorithm implementation

落花浮王杯 提交于 2019-12-03 22:15:17

Look at:

These algorithms are modifications of the Retinex algorithm (with speed improvement) although the author gave them funny names :)

There is a full source code (C++, but it is written very nicely).

Sorry for necro-posting, but it seems that there's a mistake in step 3 of your procedure that can mislead someone passing by.

In order to apply the correction, you want to divide source image by Gauss-filtered copy of it, not the Gaussian kernel itself. Approximately, in pseudo-code:

I_filtered(x,y) = G(x,y) * I(x,y)
I'(x,y) = log(I(x,y) / I_filtered(x,y))

And then apply casting of I'(x,y) to required numeric type (uint8, as I can refer from original post).

More on that topic can be found in this paper:

Ri(x, y) = log(Ii(x, y)) − log(Ii(x, y) ∗ F(x, y))

where Ii is the input image on the i-th color channel, Ri is the retinex output image on the i-th channel and F is the normalized surround function. .