Option Fftwsigma (true) to have substantially the same results FFTW Gaussianblur
This commit is contained in:
parent
6bb31aff86
commit
f1cc67bc2a
@ -33,6 +33,8 @@
|
|||||||
|
|
||||||
namespace rtengine
|
namespace rtengine
|
||||||
{
|
{
|
||||||
|
extern const Settings* settings;
|
||||||
|
|
||||||
LocallabParams locallab; ///< Local lab parameters
|
LocallabParams locallab; ///< Local lab parameters
|
||||||
|
|
||||||
void ImProcFunctions::localContrast(LabImage *lab, float **destination, const LocalContrastParams &localContrastParams, bool fftwlc, double scale)
|
void ImProcFunctions::localContrast(LabImage *lab, float **destination, const LocalContrastParams &localContrastParams, bool fftwlc, double scale)
|
||||||
@ -59,11 +61,15 @@ void ImProcFunctions::localContrast(LabImage *lab, float **destination, const Lo
|
|||||||
//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
|
//above 400 ==> 1.f
|
||||||
|
if(settings->fftwsigma == false) {//empirical formula
|
||||||
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 * sigma + bk;
|
kr = ak * sigma + bk;
|
||||||
if(sigma < 50.f) kr = 10.f;
|
if(sigma < 50.f) kr = 10.f;
|
||||||
if(sigma > 400.f) kr = 1.f;
|
if(sigma > 400.f) kr = 1.f;
|
||||||
|
} else {//sigma *= sigma
|
||||||
|
kr = sigma;
|
||||||
|
}
|
||||||
// printf("kr=%f \n", kr);
|
// printf("kr=%f \n", kr);
|
||||||
ImProcFunctions::fftw_convol_blur2(lab->L, buf, width, height, kr * sigma, 0, 0);
|
ImProcFunctions::fftw_convol_blur2(lab->L, buf, width, height, kr * sigma, 0, 0);
|
||||||
}
|
}
|
||||||
|
@ -4010,7 +4010,8 @@ void ImProcFunctions::fftw_convol_blur(float *input, float *output, int bfw, int
|
|||||||
** 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)), for some authors it is not sigma but sigma^2..I have tried...huge diffrences with Gaussianblur
|
** 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, and as there is big differences with Gaussianblur, I put an empirical correction in Ipretinex and Iplocalcontrast
|
** after several test the only result that works very well is with fftkern = 0 and algo = 0, and as there is differences with Gaussianblur, I put an empirical correction in Ipretinex and Iplocalcontrast
|
||||||
|
** you can enabled or disabled this function with rtsettings.fftwsigma in options. By defaut empirical formula is disabled
|
||||||
** in fact no importance....if it is this function (for sigma) or another... we are not in research :)
|
** in fact no importance....if it is this function (for sigma) or another... we are not in research :)
|
||||||
*/
|
*/
|
||||||
BENCHFUN
|
BENCHFUN
|
||||||
@ -4100,7 +4101,7 @@ void ImProcFunctions::fftw_convol_blur(float *input, float *output, int bfw, int
|
|||||||
for(int j = 0; j < bfh; j++){
|
for(int j = 0; j < bfh; j++){
|
||||||
int index = j * bfw;
|
int index = j * bfw;
|
||||||
for(int i = 0; i < bfw; i++)
|
for(int i = 0; i < bfw; i++)
|
||||||
out[i + index] *= exp((float)(-radius)*(n_x * i * i + n_y * j * j));//apply Gauss kernel whithout FFT - some authors says radius*radius but huge differences with Gaussianblur
|
out[i + index] *= exp((float)(-radius)*(n_x * i * i + n_y * j * j));//apply Gauss kernel whithout FFT - some authors says radius*radius but differences with Gaussianblur
|
||||||
}
|
}
|
||||||
} else if(algo == 1) {
|
} else if(algo == 1) {
|
||||||
#ifdef _OPENMP
|
#ifdef _OPENMP
|
||||||
|
@ -969,7 +969,9 @@ void ImProcFunctions::MSRLocal(int sp, bool fftw, int lum, LabImage * bufreti, L
|
|||||||
//emprical adjustement between FFTW radius and Gaussainblur
|
//emprical adjustement between FFTW radius and Gaussainblur
|
||||||
//under 50 ==> 10.f
|
//under 50 ==> 10.f
|
||||||
// 400 ==> 1.f
|
// 400 ==> 1.f
|
||||||
float sigm = RetinexScales[scale];
|
float sigm = 1.f;
|
||||||
|
if(settings->fftwsigma == false) {//empirical formula
|
||||||
|
sigm = RetinexScales[scale];
|
||||||
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;
|
||||||
@ -988,7 +990,10 @@ void ImProcFunctions::MSRLocal(int sp, bool fftw, int lum, LabImage * bufreti, L
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
} else {//sigma *= sigma
|
||||||
|
kg = 1.f;
|
||||||
|
kr = sigm;
|
||||||
|
}
|
||||||
if(!fftw) {
|
if(!fftw) {
|
||||||
#ifdef _OPENMP
|
#ifdef _OPENMP
|
||||||
#pragma omp parallel //disabled with FFTW
|
#pragma omp parallel //disabled with FFTW
|
||||||
|
@ -84,6 +84,7 @@ public:
|
|||||||
double reduchigh;
|
double reduchigh;
|
||||||
double reduclow;
|
double reduclow;
|
||||||
bool detectshape;
|
bool detectshape;
|
||||||
|
bool fftwsigma;
|
||||||
int previewselection;
|
int previewselection;
|
||||||
double cbdlsensi;
|
double cbdlsensi;
|
||||||
// bool showtooltip;
|
// bool showtooltip;
|
||||||
|
@ -596,6 +596,7 @@ void Options::setDefaults()
|
|||||||
rtSettings.detectshape = true;//experimental new detection shape
|
rtSettings.detectshape = true;//experimental new detection shape
|
||||||
rtSettings.previewselection = 5;//betwen 1 to 40
|
rtSettings.previewselection = 5;//betwen 1 to 40
|
||||||
rtSettings.cbdlsensi = 1.0;//betwen 0.001 to 1
|
rtSettings.cbdlsensi = 1.0;//betwen 0.001 to 1
|
||||||
|
rtSettings.fftwsigma = true; //choice between sigma^2 or empirical formula
|
||||||
|
|
||||||
// end locallab
|
// end locallab
|
||||||
|
|
||||||
@ -760,6 +761,10 @@ void Options::readFromFile(Glib::ustring fname)
|
|||||||
rtSettings.detectshape = keyFile.get_boolean("General", "Detectshape");
|
rtSettings.detectshape = keyFile.get_boolean("General", "Detectshape");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (keyFile.has_key("General", "Fftwsigma")) {
|
||||||
|
rtSettings.fftwsigma = keyFile.get_boolean("General", "Fftwsigma");
|
||||||
|
}
|
||||||
|
|
||||||
if (keyFile.has_key("General", "Cropsleep")) {
|
if (keyFile.has_key("General", "Cropsleep")) {
|
||||||
rtSettings.cropsleep = keyFile.get_integer("General", "Cropsleep");
|
rtSettings.cropsleep = keyFile.get_integer("General", "Cropsleep");
|
||||||
}
|
}
|
||||||
@ -1988,6 +1993,7 @@ void Options::saveToFile(Glib::ustring fname)
|
|||||||
keyFile.set_double("General", "Reduchigh", rtSettings.reduchigh);
|
keyFile.set_double("General", "Reduchigh", rtSettings.reduchigh);
|
||||||
keyFile.set_double("General", "Reduclow", rtSettings.reduclow);
|
keyFile.set_double("General", "Reduclow", rtSettings.reduclow);
|
||||||
keyFile.set_boolean("General", "Detectshape", rtSettings.detectshape);
|
keyFile.set_boolean("General", "Detectshape", rtSettings.detectshape);
|
||||||
|
keyFile.set_boolean("General", "Fftwsigma", rtSettings.fftwsigma);
|
||||||
|
|
||||||
keyFile.set_integer("External Editor", "EditorKind", editorToSendTo);
|
keyFile.set_integer("External Editor", "EditorKind", editorToSendTo);
|
||||||
keyFile.set_string("External Editor", "GimpDir", gimpDir);
|
keyFile.set_string("External Editor", "GimpDir", gimpDir);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user