another similar improvment
This commit is contained in:
parent
b371629b23
commit
dc4788e00b
@ -4009,8 +4009,9 @@ void ImProcFunctions::fftw_convol_blur(float *input, float *output, int bfw, int
|
|||||||
** radius = sigma for kernel
|
** radius = sigma for kernel
|
||||||
** n_x n_y relative width and high for kernel
|
** n_x n_y relative width and high for kernel
|
||||||
** Gaussian blur is given by G(x,y) = (1/2*PI*sigma) * exp(-(x2 + y2) / 2* sigma2)
|
** Gaussian blur is given by G(x,y) = (1/2*PI*sigma) * exp(-(x2 + y2) / 2* sigma2)
|
||||||
** its traduction in Fourier transform is G(x,y) = exp((-sigma)*(PI * x2 + PI * y2))
|
** its traduction in Fourier transform is G(x,y) = exp((-sigma)*(PI * x2 + PI * y2)), for some authors it is not sigma but sigma^2..I have tried...huge diffrences with Gaussianblur
|
||||||
** after several test the only result that works very well is with fftkern = 0 and algo = 0
|
** after several test the only result that works very well is with fftkern = 0 and algo = 0, and as there is big differences with Gaussianblur, I put an empirical correction in Ipretinex and Iplocalcontrast
|
||||||
|
** in fact no importance....if it is this function (for sigma) or another... we are not in research :)
|
||||||
*/
|
*/
|
||||||
BENCHFUN
|
BENCHFUN
|
||||||
|
|
||||||
|
@ -962,19 +962,32 @@ void ImProcFunctions::MSRLocal(int sp, bool fftw, int lum, LabImage * bufreti, L
|
|||||||
}
|
}
|
||||||
|
|
||||||
float *buffer = new float[W_L * H_L];
|
float *buffer = new float[W_L * H_L];
|
||||||
float kr = 1.f;
|
float kr = 1.f;//on FFTW
|
||||||
|
float kg = 1.f;//on Gaussianblur
|
||||||
for (int scale = scal - 1; scale >= 0; scale--) {
|
for (int scale = scal - 1; scale >= 0; scale--) {
|
||||||
// printf("retscale=%f scale=%i \n", mulradiusfftw * RetinexScales[scale], scale);
|
// printf("retscale=%f scale=%i \n", mulradiusfftw * RetinexScales[scale], scale);
|
||||||
//emprical adjustement between FFTW radius and Gaussainblur
|
//emprical adjustement between FFTW radius and Gaussainblur
|
||||||
//under 50 ==> 10.f
|
//under 50 ==> 10.f
|
||||||
//above 400 ==> 1.f
|
// 400 ==> 1.f
|
||||||
float sigm = RetinexScales[scale];
|
float sigm = RetinexScales[scale];
|
||||||
float mulradiusfftw = 1.f;
|
|
||||||
float ak = -9.f / 350.f;
|
float ak = -9.f / 350.f;
|
||||||
float bk = 10.f - 50.f * ak;
|
float bk = 10.f - 50.f * ak;
|
||||||
kr = ak * sigm + bk;
|
kr = ak * sigm + bk;
|
||||||
if(sigm < 50.f) kr = 10.f;
|
if(sigm < 50.f) kr = 10.f;
|
||||||
if(sigm > 400.f) kr = 1.f;
|
//above 400 at 5000 ==> 20.f
|
||||||
|
if(sigm > 400.f) {//increase ==> 5000
|
||||||
|
float ka = 19.f / 4600.f;
|
||||||
|
float kb = 1.f - 400 * ka;
|
||||||
|
kr = ka * sigm + kb;
|
||||||
|
float kga = -0.5f / 4600.f;
|
||||||
|
float kgb = 1.f - 400.f * kga;
|
||||||
|
kg = kga * sigm + kgb;
|
||||||
|
if(sigm > 5000.f) {
|
||||||
|
kr = ka * 5000.f + kb;
|
||||||
|
kg = kga * 5000.f + kgb;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if(!fftw) {
|
if(!fftw) {
|
||||||
#ifdef _OPENMP
|
#ifdef _OPENMP
|
||||||
@ -984,11 +997,11 @@ void ImProcFunctions::MSRLocal(int sp, bool fftw, int lum, LabImage * bufreti, L
|
|||||||
|
|
||||||
if (scale == scal - 1)
|
if (scale == scal - 1)
|
||||||
{
|
{
|
||||||
gaussianBlur(src, out, W_L, H_L, RetinexScales[scale], buffer);
|
gaussianBlur(src, out, W_L, H_L, kg * RetinexScales[scale], buffer);
|
||||||
} else // reuse result of last iteration
|
} else // reuse result of last iteration
|
||||||
{
|
{
|
||||||
// out was modified in last iteration => restore it
|
// out was modified in last iteration => restore it
|
||||||
gaussianBlur(out, out, W_L, H_L, sqrtf(SQR(RetinexScales[scale]) - SQR(RetinexScales[scale + 1])), buffer);
|
gaussianBlur(out, out, W_L, H_L, sqrtf(SQR(kg * RetinexScales[scale]) - SQR(kg * RetinexScales[scale + 1])), buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user