Speedup and some bugfixes for Noise Reduction, Issue 2557 #60
This commit is contained in:
@@ -23,7 +23,6 @@
|
||||
#include "refreshmap.h"
|
||||
#include "rt_math.h"
|
||||
#include "colortemp.h"
|
||||
//#include "../rtgui/cropguilistener.h"
|
||||
|
||||
// "ceil" rounding
|
||||
#define SKIPS(a,b) ((a) / (b) + ((a) % (b) > 0))
|
||||
@@ -168,8 +167,7 @@ void Crop::update (int todo) {
|
||||
float autoNRmax = (float) settings->nrautomax;//
|
||||
float autohigh = (float) settings->nrhigh;//
|
||||
|
||||
DirPyrDenoiseParams denoiseParams = params.dirpyrDenoise;
|
||||
denoiseParams.getCurves(noiseLCurve, noiseCCurve);
|
||||
params.dirpyrDenoise.getCurves(noiseLCurve, noiseCCurve);
|
||||
|
||||
int tilesize;
|
||||
int overlap;
|
||||
@@ -204,20 +202,18 @@ void Crop::update (int todo) {
|
||||
for(int cX=0;cX<numtiles_W;cX++) centerTile_X[cX]= tileWskip/2 + tileWskip*cX;
|
||||
for(int cY=0;cY<numtiles_H;cY++) centerTile_Y[cY]= tileHskip/2 + tileHskip*cY;
|
||||
if(settings->leveldnautsimpl==1){
|
||||
if(denoiseParams.Cmethod=="MAN" || denoiseParams.Cmethod=="PON" ) {
|
||||
PreviewProps pp (trafx, trafy, trafw*skip, trafh*skip, skip);
|
||||
parent->imgsrc->getImage (parent->currWB, tr, origCrop, pp, params.toneCurve, params.icm, params.raw );
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(denoiseParams.C2method=="MANU") {
|
||||
PreviewProps pp (trafx, trafy, trafw*skip, trafh*skip, skip);
|
||||
parent->imgsrc->getImage (parent->currWB, tr, origCrop, pp, params.toneCurve, params.icm, params.raw );
|
||||
}
|
||||
|
||||
if(params.dirpyrDenoise.Cmethod=="MAN" || params.dirpyrDenoise.Cmethod=="PON" ) {
|
||||
PreviewProps pp (trafx, trafy, trafw*skip, trafh*skip, skip);
|
||||
parent->imgsrc->getImage (parent->currWB, tr, origCrop, pp, params.toneCurve, params.icm, params.raw );
|
||||
}
|
||||
} else {
|
||||
if(params.dirpyrDenoise.C2method=="MANU") {
|
||||
PreviewProps pp (trafx, trafy, trafw*skip, trafh*skip, skip);
|
||||
parent->imgsrc->getImage (parent->currWB, tr, origCrop, pp, params.toneCurve, params.icm, params.raw );
|
||||
}
|
||||
}
|
||||
/*
|
||||
if(denoiseParams.Cmethod=="PON") {
|
||||
if(params.dirpyrDenoise.Cmethod=="PON") {
|
||||
MyTime t1dce,t2dce;
|
||||
t1dce.set();
|
||||
|
||||
@@ -227,7 +223,7 @@ void Crop::update (int todo) {
|
||||
origCropPart = new Imagefloat (crW, crH);//allocate memory
|
||||
|
||||
int skipP=1;
|
||||
if (skip==1 && denoiseParams.enabled) {//evaluate Noise
|
||||
if (skip==1 && params.dirpyrDenoise.enabled) {//evaluate Noise
|
||||
|
||||
for(int wcr=0;wcr<numtiles_W;wcr++) {
|
||||
for(int hcr=0;hcr<numtiles_H;hcr++) {
|
||||
@@ -251,7 +247,7 @@ void Crop::update (int todo) {
|
||||
|
||||
float chaut, redaut, blueaut, maxredaut, maxblueaut, minredaut, minblueaut, nresi, highresi, chromina, sigma, lumema, sigma_L;
|
||||
chaut=0.f;redaut=0.f; blueaut=0.f; maxredaut=0.f; maxblueaut=0.f;chromina=0.f; sigma=0.f;
|
||||
parent->ipf.RGB_denoise_info(provi, provi, provicalc, parent->imgsrc->isRAW(), denoiseParams, params.defringe, parent->imgsrc->getDirPyrDenoiseExpComp(), noiseLCurve,lldenoiseutili, noiseCCurve,ccdenoiseutili, chaut, redaut, blueaut, maxredaut, maxblueaut, minredaut, minblueaut, nresi, highresi, chromina, sigma, lumema, sigma_L);
|
||||
parent->ipf.RGB_denoise_info(provi, provi, provicalc, parent->imgsrc->isRAW(), params.dirpyrDenoise, params.defringe, parent->imgsrc->getDirPyrDenoiseExpComp(), noiseLCurve,lldenoiseutili, noiseCCurve,ccdenoiseutili, chaut, redaut, blueaut, maxredaut, maxblueaut, minredaut, minblueaut, nresi, highresi, chromina, sigma, lumema, sigma_L);
|
||||
//printf("DCROP skip=%d cha=%f red=%f bl=%f redM=%f bluM=%f chrom=%f sigm=%f lum=%f\n",skip, chaut,redaut,blueaut, maxredaut, maxblueaut, chromina, sigma, lumema);
|
||||
if(maxredaut > maxblueaut) {
|
||||
maxr=(maxredaut-chaut)/(autoNRmax/2.f);
|
||||
@@ -281,11 +277,10 @@ void Crop::update (int todo) {
|
||||
}
|
||||
*/
|
||||
|
||||
if((settings->leveldnautsimpl==1 && denoiseParams.Cmethod=="PRE") || (settings->leveldnautsimpl==0 && denoiseParams.C2method=="PREV")) {
|
||||
|
||||
if((settings->leveldnautsimpl==1 && params.dirpyrDenoise.Cmethod=="PRE") || (settings->leveldnautsimpl==0 && params.dirpyrDenoise.C2method=="PREV")) {
|
||||
PreviewProps pp (trafx, trafy, trafw*skip, trafh*skip, skip);
|
||||
parent->imgsrc->getImage (parent->currWB, tr, origCrop, pp, params.toneCurve, params.icm, params.raw );
|
||||
if((!isDetailWindow) && parent->adnListener && skip==1 && denoiseParams.enabled) {
|
||||
if((!isDetailWindow) && parent->adnListener && skip==1 && params.dirpyrDenoise.enabled) {
|
||||
float lowdenoise=1.f;
|
||||
int levaut=settings->leveldnaut;
|
||||
if(levaut==1) //Standard
|
||||
@@ -310,85 +305,72 @@ void Crop::update (int todo) {
|
||||
if(settings->leveldnv ==2) {crW=int(tileWskip/2);crH=int(tileHskip/2);}
|
||||
if(settings->leveldnv ==3) {crW=tileWskip-10;crH=tileHskip-10;}
|
||||
|
||||
float adjustr=1.f;
|
||||
if (params.icm.working=="ProPhoto") {adjustr =1.f;}
|
||||
else if (params.icm.working=="Adobe RGB") {adjustr = 1.f/1.3f;}
|
||||
else if (params.icm.working=="sRGB") {adjustr = 1.f/1.3f;}
|
||||
else if (params.icm.working=="WideGamut") {adjustr =1.f/1.1f;}
|
||||
else if (params.icm.working=="Beta RGB") {adjustr =1.f/1.2f;}
|
||||
else if (params.icm.working=="BestRGB") {adjustr =1.f/1.2f;}
|
||||
else if (params.icm.working=="BruceRGB") {adjustr =1.f/1.2f;}
|
||||
if(parent->adnListener)
|
||||
parent->adnListener->noiseTilePrev (centerTile_X[poscenterX], centerTile_Y[poscenterY],CenterPreview_X,CenterPreview_Y,crW, trafw*skip);
|
||||
// I have tried "blind" some solutions..to move review ...but GUI is not my truc !
|
||||
// int W,H;
|
||||
// cropgl->cropMoved (centerTile_X[poscenterX],centerTile_Y[poscenterY] , W, H);
|
||||
// cropImageListener->setPosition (int x, int y, bool update=true);
|
||||
// bool update;
|
||||
// cropImageListener->setPosition (centerTile_X[poscenterX],centerTile_Y[poscenterY] , true);
|
||||
//setCropSizes (centerTile_X[poscenterX], centerTile_Y[poscenterY], trafw*skip,trafh*skip , skip, true);
|
||||
|
||||
if (skip==1 && denoiseParams.enabled) {
|
||||
float adjustr=1.f;
|
||||
if (params.icm.working=="ProPhoto") {adjustr =1.f;}
|
||||
else if (params.icm.working=="Adobe RGB") {adjustr = 1.f/1.3f;}
|
||||
else if (params.icm.working=="sRGB") {adjustr = 1.f/1.3f;}
|
||||
else if (params.icm.working=="WideGamut") {adjustr =1.f/1.1f;}
|
||||
else if (params.icm.working=="Beta RGB") {adjustr =1.f/1.2f;}
|
||||
else if (params.icm.working=="BestRGB") {adjustr =1.f/1.2f;}
|
||||
else if (params.icm.working=="BruceRGB") {adjustr =1.f/1.2f;}
|
||||
if(parent->adnListener) parent->adnListener->noiseTilePrev (centerTile_X[poscenterX], centerTile_Y[poscenterY],CenterPreview_X,CenterPreview_Y,crW, trafw*skip);
|
||||
// I have tried "blind" some solutions..to move review ...but GUI is not my truc !
|
||||
// int W,H;
|
||||
// cropgl->cropMoved (centerTile_X[poscenterX],centerTile_Y[poscenterY] , W, H);
|
||||
// cropImageListener->setPosition (int x, int y, bool update=true);
|
||||
// bool update;
|
||||
// cropImageListener->setPosition (centerTile_X[poscenterX],centerTile_Y[poscenterY] , true);
|
||||
//setCropSizes (centerTile_X[poscenterX], centerTile_Y[poscenterY], trafw*skip,trafh*skip , skip, true);
|
||||
|
||||
Imagefloat *provi;
|
||||
Imagefloat *provicalc;
|
||||
provi = new Imagefloat (cropw, croph);//
|
||||
if(origCrop != provi)
|
||||
origCrop->copyData(provi);
|
||||
provicalc = new Imagefloat (cropw, croph);//for Luminance denoise curve
|
||||
if(origCrop != provicalc)
|
||||
origCrop->copyData(provicalc);
|
||||
|
||||
parent->imgsrc->convertColorSpace(provicalc, params.icm, parent->currWB, params.raw);//for denoise luminance curve
|
||||
|
||||
float maxr=0.f;
|
||||
float maxb=0.f;
|
||||
float chaut, redaut, blueaut, maxredaut, maxblueaut, minredaut, minblueaut, nresi, highresi, chromina, sigma, lumema, sigma_L, redyel, skinc, nsknc;
|
||||
int Nb;
|
||||
|
||||
chaut=0.f;redaut=0.f; blueaut=0.f; maxredaut=0.f; maxblueaut=0.f;minredaut=0.f; minblueaut=0.f;
|
||||
LUTf gamcurve(65536,0);
|
||||
float gam, gamthresh, gamslope;
|
||||
parent->ipf.RGB_denoise_infoGamCurve(denoiseParams, parent->imgsrc->isRAW(), gamcurve, gam, gamthresh, gamslope);
|
||||
|
||||
parent->ipf.RGB_denoise_info(provi, provi, provicalc, parent->imgsrc->isRAW(), gamcurve, gam, gamthresh, gamslope, denoiseParams, parent->imgsrc->getDirPyrDenoiseExpComp(), noiseLCurve, noiseCCurve, chaut, Nb, redaut, blueaut, maxredaut, maxblueaut, minredaut, minblueaut,nresi, highresi, chromina, sigma, lumema, sigma_L, redyel, skinc, nsknc);
|
||||
Imagefloat *provicalc = new Imagefloat (cropw, croph);//for Luminance denoise curve
|
||||
origCrop->copyData(provicalc);
|
||||
parent->imgsrc->convertColorSpace(provicalc, params.icm, parent->currWB, params.raw);//for denoise luminance curve
|
||||
float maxr=0.f;
|
||||
float maxb=0.f;
|
||||
float chaut, redaut, blueaut, maxredaut, maxblueaut, minredaut, minblueaut, nresi, highresi, chromina, sigma, lumema, sigma_L, redyel, skinc, nsknc;
|
||||
int Nb;
|
||||
|
||||
chaut=0.f;redaut=0.f; blueaut=0.f; maxredaut=0.f; maxblueaut=0.f;minredaut=0.f; minblueaut=0.f;
|
||||
LUTf gamcurve(65536,0);
|
||||
float gam, gamthresh, gamslope;
|
||||
parent->ipf.RGB_denoise_infoGamCurve(params.dirpyrDenoise, parent->imgsrc->isRAW(), gamcurve, gam, gamthresh, gamslope);
|
||||
parent->ipf.RGB_denoise_info(origCrop, provicalc, parent->imgsrc->isRAW(), gamcurve, gam, gamthresh, gamslope, params.dirpyrDenoise, parent->imgsrc->getDirPyrDenoiseExpComp(), chaut, Nb, redaut, blueaut, maxredaut, maxblueaut, minredaut, minblueaut,nresi, highresi, chromina, sigma, lumema, sigma_L, redyel, skinc, nsknc, true);
|
||||
// printf("redy=%f skin=%f pcskin=%f\n",redyel, skinc,nsknc);
|
||||
// printf("DCROP skip=%d cha=%4.0f Nb=%d red=%4.0f bl=%4.0f redM=%4.0f bluM=%4.0f L=%4.0f sigL=%4.0f Ch=%4.0f Si=%4.0f\n",skip, chaut,Nb, redaut,blueaut, maxredaut, maxblueaut, lumema, sigma_L, chromina, sigma);
|
||||
float multip=1.f;
|
||||
if(!parent->imgsrc->isRAW()) multip=2.f;//take into account gamma for TIF / JPG approximate value...not good for gamma=1
|
||||
|
||||
float maxmax=max(maxredaut,maxblueaut);
|
||||
float delta;
|
||||
int mode=0;
|
||||
// float redyel, skinc, nsknc;
|
||||
int lissage=settings->leveldnliss;
|
||||
parent->ipf.calcautodn_info (chaut, delta, Nb, levaut, maxmax, lumema, chromina, mode, lissage, redyel, skinc, nsknc);
|
||||
|
||||
|
||||
if(maxredaut > maxblueaut) {
|
||||
// maxr=(maxredaut-chaut)/((autoNRmax*multip*adjustr)/2.f);
|
||||
maxr=(delta)/((autoNRmax*multip*adjustr*lowdenoise)/2.f);
|
||||
if(minblueaut <= minredaut && minblueaut < chaut) maxb=(-chaut+minblueaut)/(autoNRmax*multip*adjustr*lowdenoise);
|
||||
}
|
||||
else {
|
||||
// maxb=(maxblueaut-chaut)/((autoNRmax*multip*adjustr)/2.f);
|
||||
maxb=(delta)/((autoNRmax*multip*adjustr*lowdenoise)/2.f);
|
||||
if(minredaut <= minblueaut && minredaut < chaut) maxr=(-chaut+minredaut)/(autoNRmax*multip*adjustr*lowdenoise);
|
||||
}//maxb mxr - empirical evaluation red / blue
|
||||
|
||||
float multip=1.f;
|
||||
if(!parent->imgsrc->isRAW()) multip=2.f;//take into account gamma for TIF / JPG approximate value...not good for gamma=1
|
||||
|
||||
denoiseParams.chroma=chaut/(autoNR*multip*adjustr*lowdenoise);
|
||||
denoiseParams.redchro=maxr;
|
||||
denoiseParams.bluechro=maxb;
|
||||
parent->adnListener->chromaChanged(denoiseParams.chroma, denoiseParams.redchro, denoiseParams.bluechro);
|
||||
|
||||
delete provicalc;
|
||||
delete provi;
|
||||
}
|
||||
float maxmax=max(maxredaut,maxblueaut);
|
||||
float delta;
|
||||
int mode=0;
|
||||
// float redyel, skinc, nsknc;
|
||||
int lissage=settings->leveldnliss;
|
||||
parent->ipf.calcautodn_info (chaut, delta, Nb, levaut, maxmax, lumema, chromina, mode, lissage, redyel, skinc, nsknc);
|
||||
|
||||
|
||||
if(maxredaut > maxblueaut) {
|
||||
// maxr=(maxredaut-chaut)/((autoNRmax*multip*adjustr)/2.f);
|
||||
maxr=(delta)/((autoNRmax*multip*adjustr*lowdenoise)/2.f);
|
||||
if(minblueaut <= minredaut && minblueaut < chaut) maxb=(-chaut+minblueaut)/(autoNRmax*multip*adjustr*lowdenoise);
|
||||
}
|
||||
else {
|
||||
// maxb=(maxblueaut-chaut)/((autoNRmax*multip*adjustr)/2.f);
|
||||
maxb=(delta)/((autoNRmax*multip*adjustr*lowdenoise)/2.f);
|
||||
if(minredaut <= minblueaut && minredaut < chaut) maxr=(-chaut+minredaut)/(autoNRmax*multip*adjustr*lowdenoise);
|
||||
}//maxb mxr - empirical evaluation red / blue
|
||||
|
||||
|
||||
params.dirpyrDenoise.chroma=chaut/(autoNR*multip*adjustr*lowdenoise);
|
||||
params.dirpyrDenoise.redchro=maxr;
|
||||
params.dirpyrDenoise.bluechro=maxb;
|
||||
parent->adnListener->chromaChanged(params.dirpyrDenoise.chroma, params.dirpyrDenoise.redchro, params.dirpyrDenoise.bluechro);
|
||||
|
||||
delete provicalc;
|
||||
}
|
||||
}
|
||||
|
||||
if((settings->leveldnautsimpl==1 && denoiseParams.Cmethod=="AUT") || (settings->leveldnautsimpl==0 && denoiseParams.C2method=="AUTO")) {
|
||||
|
||||
if(skip==1 && params.dirpyrDenoise.enabled && ((settings->leveldnautsimpl==1 && params.dirpyrDenoise.Cmethod=="AUT") || (settings->leveldnautsimpl==0 && params.dirpyrDenoise.C2method=="AUTO"))) {
|
||||
MyTime t1aue,t2aue;
|
||||
t1aue.set();
|
||||
|
||||
@@ -403,68 +385,63 @@ void Crop::update (int todo) {
|
||||
int levaut=settings->leveldnaut;
|
||||
if(levaut==1) //Standard
|
||||
lowdenoise=0.7f;
|
||||
|
||||
|
||||
if (skip==1 && denoiseParams.enabled) {//evaluate Noise
|
||||
LUTf gamcurve(65536,0);
|
||||
float gam, gamthresh, gamslope;
|
||||
parent->ipf.RGB_denoise_infoGamCurve(denoiseParams, parent->imgsrc->isRAW(), gamcurve, gam, gamthresh, gamslope);
|
||||
parent->ipf.RGB_denoise_infoGamCurve(params.dirpyrDenoise, parent->imgsrc->isRAW(), gamcurve, gam, gamthresh, gamslope);
|
||||
int Nb[9];
|
||||
#ifdef _OPENMP
|
||||
#pragma omp parallel
|
||||
#endif
|
||||
{
|
||||
Imagefloat *origCropPart;//init auto noise
|
||||
origCropPart = new Imagefloat (crW, crH);//allocate memory
|
||||
Imagefloat *provicalc;
|
||||
provicalc = new Imagefloat (crW, crH);
|
||||
|
||||
#pragma omp parallel
|
||||
{
|
||||
Imagefloat *origCropPart;//init auto noise
|
||||
origCropPart = new Imagefloat (crW, crH);//allocate memory
|
||||
Imagefloat *provi;
|
||||
Imagefloat *provicalc;
|
||||
provi = new Imagefloat (crW, crH);
|
||||
provicalc = new Imagefloat (crW, crH);
|
||||
|
||||
int coordW[3];//coordonate of part of image to mesure noise
|
||||
int coordH[3];
|
||||
int begW=50;
|
||||
int begH=50;
|
||||
coordW[0]=begW;coordW[1]=widIm/2-crW/2;coordW[2]=widIm-crW-begW;
|
||||
coordH[0]=begH;coordH[1]=heiIm/2-crH/2;coordH[2]=heiIm-crH-begH;
|
||||
#pragma omp for schedule(dynamic) collapse(2) nowait
|
||||
for(int wcr=0;wcr<=2;wcr++) {
|
||||
for(int hcr=0;hcr<=2;hcr++) {
|
||||
PreviewProps ppP (coordW[wcr] , coordH[hcr], crW, crH, skipP);
|
||||
parent->imgsrc->getImage (parent->currWB, tr, origCropPart, ppP, params.toneCurve, params.icm, params.raw );
|
||||
|
||||
if(origCropPart != provi)
|
||||
origCropPart->copyData(provi);
|
||||
if(origCropPart != provicalc)
|
||||
origCropPart->copyData(provicalc);
|
||||
parent->imgsrc->convertColorSpace(provicalc, params.icm, parent->currWB, params.raw);//for denoise luminance curve
|
||||
//float maxr=0.f;
|
||||
//float maxb=0.f;
|
||||
float pondcorrec=1.0f;
|
||||
float chaut=0.f, redaut=0.f, blueaut=0.f, maxredaut=0.f, maxblueaut=0.f, minredaut=0.f, minblueaut=0.f, nresi=0.f, highresi=0.f, chromina=0.f, sigma=0.f, lumema=0.f, sigma_L=0.f, redyel=0.f, skinc=0.f, nsknc=0.f;
|
||||
int nb=0;
|
||||
int coordW[3];//coordonate of part of image to mesure noise
|
||||
int coordH[3];
|
||||
int begW=50;
|
||||
int begH=50;
|
||||
coordW[0]=begW;coordW[1]=widIm/2-crW/2;coordW[2]=widIm-crW-begW;
|
||||
coordH[0]=begH;coordH[1]=heiIm/2-crH/2;coordH[2]=heiIm-crH-begH;
|
||||
#ifdef _OPENMP
|
||||
#pragma omp for schedule(dynamic) collapse(2) nowait
|
||||
#endif
|
||||
for(int wcr=0;wcr<=2;wcr++) {
|
||||
for(int hcr=0;hcr<=2;hcr++) {
|
||||
PreviewProps ppP (coordW[wcr] , coordH[hcr], crW, crH, skipP);
|
||||
parent->imgsrc->getImage (parent->currWB, tr, origCropPart, ppP, params.toneCurve, params.icm, params.raw );
|
||||
|
||||
if(origCropPart != provicalc)
|
||||
origCropPart->copyData(provicalc);
|
||||
parent->imgsrc->convertColorSpace(provicalc, params.icm, parent->currWB, params.raw);//for denoise luminance curve
|
||||
//float maxr=0.f;
|
||||
//float maxb=0.f;
|
||||
float pondcorrec=1.0f;
|
||||
float chaut=0.f, redaut=0.f, blueaut=0.f, maxredaut=0.f, maxblueaut=0.f, minredaut=0.f, minblueaut=0.f, nresi=0.f, highresi=0.f, chromina=0.f, sigma=0.f, lumema=0.f, sigma_L=0.f, redyel=0.f, skinc=0.f, nsknc=0.f;
|
||||
int nb=0;
|
||||
// chaut=0.f;redaut=0.f; blueaut=0.f; maxredaut=0.f; maxblueaut=0.f; chromina=0.f; sigma=0.f;
|
||||
parent->ipf.RGB_denoise_info(provi, provi, provicalc, parent->imgsrc->isRAW(), gamcurve, gam, gamthresh, gamslope, denoiseParams, parent->imgsrc->getDirPyrDenoiseExpComp(), noiseLCurve, noiseCCurve, chaut, nb, redaut, blueaut, maxredaut, maxblueaut, minredaut, minblueaut, nresi, highresi, chromina, sigma, lumema, sigma_L, redyel, skinc, nsknc);
|
||||
parent->ipf.RGB_denoise_info(origCropPart, provicalc, parent->imgsrc->isRAW(), gamcurve, gam, gamthresh, gamslope, params.dirpyrDenoise, parent->imgsrc->getDirPyrDenoiseExpComp(), chaut, nb, redaut, blueaut, maxredaut, maxblueaut, minredaut, minblueaut, nresi, highresi, chromina, sigma, lumema, sigma_L, redyel, skinc, nsknc);
|
||||
|
||||
//printf("DCROP skip=%d cha=%f red=%f bl=%f redM=%f bluM=%f chrom=%f sigm=%f lum=%f\n",skip, chaut,redaut,blueaut, maxredaut, maxblueaut, chromina, sigma, lumema);
|
||||
Nb[hcr*3 + wcr] = nb;
|
||||
ch_M[hcr*3 + wcr]=pondcorrec*chaut;
|
||||
max_r[hcr*3 + wcr]=pondcorrec*maxredaut;
|
||||
max_b[hcr*3 + wcr]=pondcorrec*maxblueaut;
|
||||
min_r[hcr*3 + wcr]=pondcorrec*minredaut;
|
||||
min_b[hcr*3 + wcr]=pondcorrec*minblueaut;
|
||||
lumL[hcr*3 + wcr]=lumema;
|
||||
chromC[hcr*3 + wcr]=chromina;
|
||||
ry[hcr*3 + wcr]=redyel;
|
||||
sk[hcr*3 + wcr]=skinc;
|
||||
pcsk[hcr*3 + wcr]=nsknc;
|
||||
|
||||
|
||||
//printf("DCROP skip=%d cha=%f red=%f bl=%f redM=%f bluM=%f chrom=%f sigm=%f lum=%f\n",skip, chaut,redaut,blueaut, maxredaut, maxblueaut, chromina, sigma, lumema);
|
||||
Nb[hcr*3 + wcr] = nb;
|
||||
ch_M[hcr*3 + wcr]=pondcorrec*chaut;
|
||||
max_r[hcr*3 + wcr]=pondcorrec*maxredaut;
|
||||
max_b[hcr*3 + wcr]=pondcorrec*maxblueaut;
|
||||
min_r[hcr*3 + wcr]=pondcorrec*minredaut;
|
||||
min_b[hcr*3 + wcr]=pondcorrec*minblueaut;
|
||||
lumL[hcr*3 + wcr]=lumema;
|
||||
chromC[hcr*3 + wcr]=chromina;
|
||||
ry[hcr*3 + wcr]=redyel;
|
||||
sk[hcr*3 + wcr]=skinc;
|
||||
pcsk[hcr*3 + wcr]=nsknc;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
delete provicalc;
|
||||
delete provi;
|
||||
delete origCropPart;
|
||||
}
|
||||
}
|
||||
float chM=0.f;
|
||||
float MaxR=0.f;
|
||||
float MaxB=0.f;
|
||||
@@ -480,86 +457,82 @@ void Crop::update (int todo) {
|
||||
float MaxBMoy=0.f;
|
||||
float MinRMoy=0.f;
|
||||
float MinBMoy=0.f;
|
||||
|
||||
|
||||
float multip=1.f;
|
||||
if(!parent->imgsrc->isRAW()) multip=2.f;//take into account gamma for TIF / JPG approximate value...not good fot gamma=1
|
||||
float adjustr=1.f;
|
||||
if (params.icm.working=="ProPhoto") {adjustr =1.f;}//
|
||||
else if (params.icm.working=="Adobe RGB") {adjustr = 1.f/1.3f;}
|
||||
else if (params.icm.working=="sRGB") {adjustr = 1.f/1.3f;}
|
||||
else if (params.icm.working=="WideGamut") {adjustr =1.f/1.1f;}
|
||||
else if (params.icm.working=="Beta RGB") {adjustr =1.f/1.2f;}
|
||||
else if (params.icm.working=="BestRGB") {adjustr =1.f/1.2f;}
|
||||
else if (params.icm.working=="BruceRGB") {adjustr =1.f/1.2f;}
|
||||
if (params.icm.working=="ProPhoto") {adjustr =1.f;}//
|
||||
else if (params.icm.working=="Adobe RGB") {adjustr = 1.f/1.3f;}
|
||||
else if (params.icm.working=="sRGB") {adjustr = 1.f/1.3f;}
|
||||
else if (params.icm.working=="WideGamut") {adjustr =1.f/1.1f;}
|
||||
else if (params.icm.working=="Beta RGB") {adjustr =1.f/1.2f;}
|
||||
else if (params.icm.working=="BestRGB") {adjustr =1.f/1.2f;}
|
||||
else if (params.icm.working=="BruceRGB") {adjustr =1.f/1.2f;}
|
||||
|
||||
float maxmax;
|
||||
float minmin;
|
||||
float delta[9];
|
||||
int mode=1;
|
||||
float redyel, skinc, nsknc;
|
||||
int lissage=settings->leveldnliss;
|
||||
for(int k=0;k<9;k++) {
|
||||
maxmax=max(max_r[k],max_b[k]);
|
||||
parent->ipf.calcautodn_info (ch_M[k], delta[k], Nb[k], levaut, maxmax,lumL[k],chromC[k], mode, lissage, ry[k], sk[k], pcsk[k]);
|
||||
// printf("ch_M=%f delta=%f\n",ch_M[k], delta[k]);
|
||||
}
|
||||
for(int k=0;k<9;k++) {
|
||||
if(max_r[k] > max_b[k]) {
|
||||
minmin=min(min_r[k],min_b[k]);
|
||||
Max_R[k]=(delta[k])/((autoNRmax*multip*adjustr*lowdenoise)/2.f);
|
||||
Min_B[k]= -(ch_M[k]- min_b[k])/(autoNRmax*multip*adjustr*lowdenoise);
|
||||
Max_B[k]=0.f;
|
||||
Min_R[k]=0.f;
|
||||
}
|
||||
else {
|
||||
minmin=min(min_r[k],min_b[k]);
|
||||
Max_B[k]=(delta[k])/((autoNRmax*multip*adjustr*lowdenoise)/2.f);
|
||||
Min_R[k]=- (ch_M[k]-min_r[k]) / (autoNRmax*multip*adjustr*lowdenoise);
|
||||
Min_B[k]=0.f;
|
||||
Max_R[k]=0.f;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
for(int k=0;k<9;k++) {
|
||||
// printf("ch_M= %f Max_R=%f Max_B=%f min_r=%f min_b=%f\n",ch_M[k],Max_R[k], Max_B[k],Min_R[k], Min_B[k]);
|
||||
chM+=ch_M[k];
|
||||
MaxBMoy+=Max_B[k];
|
||||
MaxRMoy+=Max_R[k];
|
||||
MinRMoy+=Min_R[k];
|
||||
MinBMoy+=Min_B[k];
|
||||
|
||||
if(Max_R[k]>MaxR) MaxR=Max_R[k];
|
||||
if(Max_B[k]>MaxB) MaxB=Max_B[k];
|
||||
if(Min_R[k]<MinR) MinR=Min_R[k];
|
||||
if(Min_B[k]<MinB) MinB=Min_B[k];
|
||||
|
||||
}
|
||||
chM/=9;
|
||||
MaxBMoy/=9;
|
||||
MaxRMoy/=9;
|
||||
MinBMoy/=9;
|
||||
MinRMoy/=9;
|
||||
|
||||
if(MaxR > MaxB) {
|
||||
maxr=MaxRMoy + (MaxR-MaxRMoy)*0.66f;//#std Dev
|
||||
//maxb=MinB;
|
||||
maxb=MinBMoy + (MinB-MinBMoy)*0.66f;
|
||||
|
||||
float maxmax;
|
||||
float minmin;
|
||||
float delta[9];
|
||||
int mode=1;
|
||||
float redyel, skinc, nsknc;
|
||||
int lissage=settings->leveldnliss;
|
||||
for (int k=0;k<9;k++) {
|
||||
maxmax=max(max_r[k],max_b[k]);
|
||||
parent->ipf.calcautodn_info (ch_M[k], delta[k], Nb[k], levaut, maxmax,lumL[k],chromC[k], mode, lissage, ry[k], sk[k], pcsk[k]);
|
||||
// printf("ch_M=%f delta=%f\n",ch_M[k], delta[k]);
|
||||
}
|
||||
for (int k=0;k<9;k++) {
|
||||
if(max_r[k] > max_b[k]) {
|
||||
minmin=min(min_r[k],min_b[k]);
|
||||
Max_R[k]=(delta[k])/((autoNRmax*multip*adjustr*lowdenoise)/2.f);
|
||||
Min_B[k]= -(ch_M[k]- min_b[k])/(autoNRmax*multip*adjustr*lowdenoise);
|
||||
Max_B[k]=0.f;
|
||||
Min_R[k]=0.f;
|
||||
}
|
||||
else {
|
||||
maxb=MaxBMoy + (MaxB-MaxBMoy)*0.66f;
|
||||
maxr=MinRMoy + (MinR-MinRMoy)*0.66f;
|
||||
minmin=min(min_r[k],min_b[k]);
|
||||
Max_B[k]=(delta[k])/((autoNRmax*multip*adjustr*lowdenoise)/2.f);
|
||||
Min_R[k]=- (ch_M[k]-min_r[k]) / (autoNRmax*multip*adjustr*lowdenoise);
|
||||
Min_B[k]=0.f;
|
||||
Max_R[k]=0.f;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (int k=0;k<9;k++) {
|
||||
// printf("ch_M= %f Max_R=%f Max_B=%f min_r=%f min_b=%f\n",ch_M[k],Max_R[k], Max_B[k],Min_R[k], Min_B[k]);
|
||||
chM+=ch_M[k];
|
||||
MaxBMoy+=Max_B[k];
|
||||
MaxRMoy+=Max_R[k];
|
||||
MinRMoy+=Min_R[k];
|
||||
MinBMoy+=Min_B[k];
|
||||
|
||||
if(Max_R[k]>MaxR) MaxR=Max_R[k];
|
||||
if(Max_B[k]>MaxB) MaxB=Max_B[k];
|
||||
if(Min_R[k]<MinR) MinR=Min_R[k];
|
||||
if(Min_B[k]<MinB) MinB=Min_B[k];
|
||||
}
|
||||
chM/=9;
|
||||
MaxBMoy/=9;
|
||||
MaxRMoy/=9;
|
||||
MinBMoy/=9;
|
||||
MinRMoy/=9;
|
||||
|
||||
if(MaxR > MaxB) {
|
||||
maxr=MaxRMoy + (MaxR-MaxRMoy)*0.66f;//#std Dev
|
||||
//maxb=MinB;
|
||||
maxb=MinBMoy + (MinB-MinBMoy)*0.66f;
|
||||
}
|
||||
else {
|
||||
maxb=MaxBMoy + (MaxB-MaxBMoy)*0.66f;
|
||||
maxr=MinRMoy + (MinR-MinRMoy)*0.66f;
|
||||
}
|
||||
|
||||
// printf("DCROP skip=%d cha=%f red=%f bl=%f \n",skip, chM,maxr,maxb);
|
||||
denoiseParams.chroma=chM/(autoNR*multip*adjustr);
|
||||
denoiseParams.redchro=maxr;
|
||||
denoiseParams.bluechro=maxb;
|
||||
if(parent->adnListener) {
|
||||
parent->adnListener->chromaChanged(denoiseParams.chroma, denoiseParams.redchro, denoiseParams.bluechro);
|
||||
}
|
||||
}
|
||||
params.dirpyrDenoise.chroma=chM/(autoNR*multip*adjustr);
|
||||
params.dirpyrDenoise.redchro=maxr;
|
||||
params.dirpyrDenoise.bluechro=maxb;
|
||||
if(parent->adnListener) {
|
||||
parent->adnListener->chromaChanged(params.dirpyrDenoise.chroma, params.dirpyrDenoise.redchro, params.dirpyrDenoise.bluechro);
|
||||
}
|
||||
if (settings->verbose) {
|
||||
t2aue.set();
|
||||
printf("Info denoise auto performed in %d usec:\n", t2aue.etime(t1aue));
|
||||
@@ -567,13 +540,14 @@ void Crop::update (int todo) {
|
||||
|
||||
//end evaluate noise
|
||||
}
|
||||
// if(denoiseParams.Cmethod=="AUT" || denoiseParams.Cmethod=="PON") {//reinit origCrop after Auto
|
||||
if((settings->leveldnautsimpl==1 && denoiseParams.Cmethod=="AUT") || (settings->leveldnautsimpl==0 && denoiseParams.C2method=="AUTO")) {//reinit origCrop after Auto
|
||||
// if(params.dirpyrDenoise.Cmethod=="AUT" || params.dirpyrDenoise.Cmethod=="PON") {//reinit origCrop after Auto
|
||||
if((settings->leveldnautsimpl==1 && params.dirpyrDenoise.Cmethod=="AUT") || (settings->leveldnautsimpl==0 && params.dirpyrDenoise.C2method=="AUTO")) {//reinit origCrop after Auto
|
||||
PreviewProps pp (trafx, trafy, trafw*skip, trafh*skip, skip);
|
||||
parent->imgsrc->getImage (parent->currWB, tr, origCrop, pp, params.toneCurve, params.icm, params.raw );
|
||||
}
|
||||
DirPyrDenoiseParams denoiseParams = params.dirpyrDenoise;
|
||||
|
||||
if(denoiseParams.Lmethod == "CUR") {
|
||||
if(params.dirpyrDenoise.Lmethod == "CUR") {
|
||||
if(noiseLCurve)
|
||||
denoiseParams.luma = 0.5f; //very small value to init process - select curve or slider
|
||||
else
|
||||
@@ -585,8 +559,7 @@ void Crop::update (int todo) {
|
||||
|
||||
if((noiseLCurve || noiseCCurve ) && skip==1 && denoiseParams.enabled) {//only allocate memory if enabled and skip
|
||||
calclum = new Imagefloat (cropw, croph);//for Luminance denoise curve
|
||||
if(origCrop != calclum)
|
||||
origCrop->copyData(calclum);
|
||||
origCrop->copyData(calclum);
|
||||
|
||||
parent->imgsrc->convertColorSpace(calclum, params.icm, parent->currWB, params.raw);//for denoise luminance curve
|
||||
}
|
||||
@@ -598,15 +571,13 @@ void Crop::update (int todo) {
|
||||
|
||||
float chaut, redaut, blueaut, maxredaut, maxblueaut, nresi, highresi;
|
||||
parent->ipf.RGB_denoise(kall, origCrop, origCrop, calclum, ch_M, max_r, max_b, parent->imgsrc->isRAW(), /*Roffset,*/ denoiseParams, parent->imgsrc->getDirPyrDenoiseExpComp(), noiseLCurve, noiseCCurve, chaut, redaut, blueaut, maxredaut, maxblueaut, nresi, highresi);
|
||||
if(parent->adnListener) parent->adnListener->noiseChanged(nresi, highresi);
|
||||
if(settings->leveldnautsimpl==1) {
|
||||
if((denoiseParams.Cmethod=="AUT" || denoiseParams.Cmethod=="PRE") && (parent->adnListener)) // force display value of sliders
|
||||
parent->adnListener->chromaChanged(denoiseParams.chroma, denoiseParams.redchro, denoiseParams.bluechro);
|
||||
}
|
||||
else {
|
||||
if((denoiseParams.C2method=="AUTO" || denoiseParams.C2method=="PREV") && (parent->adnListener)) // force display value of sliders
|
||||
parent->adnListener->chromaChanged(denoiseParams.chroma, denoiseParams.redchro, denoiseParams.bluechro);
|
||||
|
||||
if (parent->adnListener) parent->adnListener->noiseChanged(nresi, highresi);
|
||||
if (settings->leveldnautsimpl == 1) {
|
||||
if ((denoiseParams.Cmethod == "AUT" || denoiseParams.Cmethod == "PRE") && (parent->adnListener)) // force display value of sliders
|
||||
parent->adnListener->chromaChanged(denoiseParams.chroma, denoiseParams.redchro, denoiseParams.bluechro);
|
||||
} else {
|
||||
if((denoiseParams.C2method == "AUTO" || denoiseParams.C2method == "PREV") && (parent->adnListener)) // force display value of sliders
|
||||
parent->adnListener->chromaChanged(denoiseParams.chroma, denoiseParams.redchro, denoiseParams.bluechro);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user