Simplify transition code

This commit is contained in:
Desmis 2019-11-30 13:41:01 +01:00
parent 6e61e8f1fc
commit f9a19bd621

View File

@ -2083,8 +2083,7 @@ void ImProcFunctions::DeNoise_Local(int call, const struct local_params& lp, La
}
switch (zone) {
case 1: { // inside transition zone
if (zone > 0) {
float difL, difa, difb;
if (call == 2 /*|| call == 1 || call == 3 */) { //simpleprocess
@ -2114,40 +2113,7 @@ void ImProcFunctions::DeNoise_Local(int call, const struct local_params& lp, La
transformed->b[y][x] = (10.f * difb);// * 10.f empirical to can visualize modifications
}
break;
}
case 2: { // inside selection => full effect, no transition
float difL, difa, difb;
if (call == 2 /*|| call == 1 || call == 3 */) { //simpleprocess
difL = tmp1.L[loy - begy][lox - begx] - original->L[y][x];
difa = tmp1.a[loy - begy][lox - begx] - original->a[y][x];
difb = tmp1.b[loy - begy][lox - begx] - original->b[y][x];
} else { //dcrop
difL = tmp1.L[y][x] - original->L[y][x];
difa = tmp1.a[y][x] - original->a[y][x];
difb = tmp1.b[y][x] - original->b[y][x];
}
difL *= reducdEL;
difa *= reducdEa;
difb *= reducdEb;
transformed->L[y][x] = CLIP(original->L[y][x] + difL);
transformed->a[y][x] = CLIPC((original->a[y][x] + difa) * factnoise);
transformed->b[y][x] = CLIPC((original->b[y][x] + difb) * factnoise);
if (blshow) {
transformed->L[y][x] = CLIP(12000.f + 10.f * difL);// * 10.f empirical to can visualize modifications
transformed->a[y][x] = CLIPC(10.f * difa);// * 10.f empirical to can visualize modifications
transformed->b[y][x] = CLIPC(10.f * difb);// * 10.f empirical to can visualize modifications
} else if (previewbl) {
transformed->a[y][x] = 0.f;
transformed->b[y][x] = (10.f * difb);// * 10.f empirical to can visualize modifications
}
}
}
}
@ -2295,7 +2261,7 @@ void ImProcFunctions::InverseReti_Local(const struct local_params & lp, const fl
float kab = 1.f;
balancedeltaE(kL, kab);
LabImage *origblur = new LabImage(GW, GH);
std::unique_ptr<LabImage> origblur(new LabImage(GW, GH));
float radius = 3.f / sk;
#ifdef _OPENMP
@ -2400,7 +2366,6 @@ void ImProcFunctions::InverseReti_Local(const struct local_params & lp, const fl
}
}
delete origblur;
}
@ -2855,28 +2820,14 @@ static void blendmask(const local_params& lp, int xstart, int ystart, int cx, in
originalmas->L[y][x] = CLIP(bufexporig->L[y][x] - bufmaskor->L[y][x]);
originalmas->a[y][x] = CLIPC(bufexporig->a[y][x] * (1.f - bufmaskor->a[y][x]));
originalmas->b[y][x] = CLIPC(bufexporig->b[y][x] * (1.f - bufmaskor->b[y][x]));
switch (zone) {
case 1: {
original->L[y + ystart][x + xstart] += (bl * localFactor * bufmaskor->L[y][x]);
original->a[y + ystart][x + xstart] *= (1.f + bl * localFactor * bufmaskor->a[y][x]);
original->b[y + ystart][x + xstart] *= (1.f + bl * localFactor * bufmaskor->b[y][x]);
original->L[y + ystart][x + xstart] = CLIP(original->L[y + ystart][x + xstart]);
original->a[y + ystart][x + xstart] = CLIPC(original->a[y + ystart][x + xstart]);
original->b[y + ystart][x + xstart] = CLIPC(original->b[y + ystart][x + xstart]);
break;
}
case 2: {
original->L[y + ystart][x + xstart] += (bl * bufmaskor->L[y][x]);
original->a[y + ystart][x + xstart] *= (1.f + bl * bufmaskor->a[y][x]);
original->b[y + ystart][x + xstart] *= (1.f + bl * bufmaskor->b[y][x]);
original->L[y + ystart][x + xstart] = CLIP(original->L[y + ystart][x + xstart]);
original->a[y + ystart][x + xstart] = CLIPC(original->a[y + ystart][x + xstart]);
original->b[y + ystart][x + xstart] = CLIPC(original->b[y + ystart][x + xstart]);
}
}
}
} else if (inv == 1) {
localFactor = 1.f - localFactor;
@ -3968,7 +3919,7 @@ void ImProcFunctions::InverseSharp_Local(float **loctemp, const float hueref, co
float kab = 1.f;
balancedeltaE(kL, kab);
LabImage *origblur = new LabImage(GW, GH);
std::unique_ptr<LabImage> origblur(new LabImage(GW, GH));
float radius = 3.f / sk;
#ifdef _OPENMP
@ -4039,7 +3990,6 @@ void ImProcFunctions::InverseSharp_Local(float **loctemp, const float hueref, co
}
}
}
delete origblur;
}
@ -4165,7 +4115,7 @@ void ImProcFunctions::Exclude_Local(float **deltaso, float hueref, float chromar
sobelref = log1p(sobelref);
LabImage *origblur = new LabImage(GW, GH);
std::unique_ptr<LabImage> origblur(new LabImage(GW, GH));
const float radius = 3.f / sk;
@ -4248,9 +4198,8 @@ void ImProcFunctions::Exclude_Local(float **deltaso, float hueref, float chromar
const float affde = reducdE;
if (rL > 32.768f) { //to avoid crash with very low gamut in rare cases ex : L=0.01 a=0.5 b=-0.9
switch (zone) {
if (zone > 0) {
case 1: { // inside transition zone
const float difL = (rsv->L[loy - begy][lox - begx] - original->L[y][x]) * localFactor;
transformed->L[y][x] = CLIP(original->L[y][x] + difL * affsob * affde);
@ -4260,27 +4209,12 @@ void ImProcFunctions::Exclude_Local(float **deltaso, float hueref, float chromar
const float difb = (rsv->b[loy - begy][lox - begx] - original->b[y][x]) * localFactor;
transformed->b[y][x] = CLIPC(original->b[y][x] + difb * affsob * affde);
break;
}
case 2: { // inside selection => full effect, no transition
const float difL = rsv->L[loy - begy][lox - begx] - original->L[y][x];
transformed->L[y][x] = CLIP(original->L[y][x] + difL * affsob * affde);
const float difa = rsv->a[loy - begy][lox - begx] - original->a[y][x];;
transformed->a[y][x] = CLIPC(original->a[y][x] + difa * affsob * affde);
const float difb = rsv->b[loy - begy][lox - begx] - original->b[y][x];
transformed->b[y][x] = CLIPC(original->b[y][x] + difb * affsob * affde);
}
}
}
}
}
}
delete origblur;
}
}