Save provisory work
This commit is contained in:
@@ -41,6 +41,7 @@
|
||||
#include "../rtgui/thresholdselector.h"
|
||||
|
||||
#include "cplx_wavelet_dec.h"
|
||||
#include "ciecam02.h"
|
||||
|
||||
#define BENCHMARK
|
||||
#include "StopWatch.h"
|
||||
@@ -163,6 +164,7 @@ struct local_params {
|
||||
double expcomp;
|
||||
int excmet;
|
||||
int strucc;
|
||||
int war;
|
||||
|
||||
|
||||
};
|
||||
@@ -383,6 +385,7 @@ static void calcLocalParams(int oW, int oH, const LocallabParams& locallab, stru
|
||||
int local_sensitm = locallab.sensitm;
|
||||
int local_sensiexclu = locallab.sensiexclu;
|
||||
int local_struc = locallab.struc;
|
||||
int local_warm = locallab.warm;
|
||||
int local_sensih = locallab.sensih;
|
||||
int local_sensicb = locallab.sensicb;
|
||||
int local_contrast = locallab.contrast;
|
||||
@@ -487,7 +490,7 @@ static void calcLocalParams(int oW, int oH, const LocallabParams& locallab, stru
|
||||
lp.expcomp = locallab.expcomp / 100.;
|
||||
lp.sensex = local_sensiex;
|
||||
lp.strucc = local_struc;
|
||||
|
||||
lp.war = local_warm;
|
||||
}
|
||||
|
||||
static void calcTransition(const float lox, const float loy, const float ach, const local_params& lp, int &zone, float &localFactor)
|
||||
@@ -654,6 +657,295 @@ void ImProcFunctions::strcurv_data(std::string retistr, int *s_datc, int &siz)
|
||||
|
||||
}
|
||||
|
||||
// Copyright (c) 2017 Jacques Desmis <jdesmis@gmail.com>
|
||||
void ImProcFunctions::ciecamloc_02float(CieImage* ncie, LabImage* lab, LabImage* dest)
|
||||
{
|
||||
printf("OK CIELOCAL\n");
|
||||
//#ifdef _DEBUG
|
||||
MyTime t1e, t2e;
|
||||
t1e.set();
|
||||
//#endif
|
||||
int width = lab->W, height = lab->H;
|
||||
float Yw;
|
||||
Yw = 1.0f;
|
||||
double Xw, Zw;
|
||||
float f = 0.f, nc = 0.f, la, c = 0.f, xw, yw, zw, f2 = 1.f, c2 = 1.f, nc2 = 1.f, yb2;
|
||||
float fl, n, nbb, ncb, aw; //d
|
||||
float xwd, ywd, zwd, xws, yws, zws;
|
||||
int alg = 0;
|
||||
double Xwout, Zwout;
|
||||
double Xwsc, Zwsc;
|
||||
|
||||
// const bool epdEnabled = params->epd.enabled;
|
||||
|
||||
ColorTemp::temp2mulxyz(params->wb.temperature, params->wb.method, Xw, Zw); //compute white Xw Yw Zw : white current WB
|
||||
ColorTemp::temp2mulxyz(5000.f + 35.f * params->locallab.warm, "Custom", Xwout, Zwout);
|
||||
ColorTemp::temp2mulxyz(5000., "Custom", Xwsc, Zwsc);
|
||||
|
||||
//viewing condition for surrsrc
|
||||
f = 1.00f;
|
||||
c = 0.69f;
|
||||
nc = 1.00f;
|
||||
//viewing condition for surround
|
||||
f2 = 1.0f, c2 = 0.69f, nc2 = 1.0f;
|
||||
//with which algorithm
|
||||
alg = 0;
|
||||
|
||||
|
||||
xwd = 100.f * Xwout;
|
||||
zwd = 100.f * Zwout;
|
||||
ywd = 100.f;
|
||||
|
||||
xws = 100.f * Xwsc;
|
||||
zws = 100.f * Zwsc;
|
||||
yws = 100.f;
|
||||
|
||||
|
||||
yb2 = 18;
|
||||
//La and la2 = ambiant luminosity scene and viewing
|
||||
la = 400.f;
|
||||
const float la2 = 400.f;
|
||||
const float pilot = 100.f;
|
||||
const float pilotout = 100.f;
|
||||
|
||||
//algoritm's params
|
||||
const float rstprotection = 100. ;//- params->colorappearance.rstprotection;
|
||||
LUTu hist16J;
|
||||
LUTu hist16Q;
|
||||
float yb = 18.f;
|
||||
float d, dj;
|
||||
|
||||
const int gamu = 0; //(params->colorappearance.gamut) ? 1 : 0;
|
||||
xw = 100.0f * Xw;
|
||||
yw = 100.0f * Yw;
|
||||
zw = 100.0f * Zw;
|
||||
float xw1 = 0.f, yw1 = 0.f, zw1 = 0.f, xw2 = 0.f, yw2 = 0.f, zw2 = 0.f;
|
||||
// free temp and green
|
||||
xw1 = xws;
|
||||
yw1 = yws;
|
||||
zw1 = zws;
|
||||
xw2 = xwd;
|
||||
yw2 = ywd;
|
||||
zw2 = zwd;
|
||||
|
||||
float cz, wh, pfl;
|
||||
Ciecam02::initcam1float(gamu, yb, pilot, f, la, xw, yw, zw, n, d, nbb, ncb, cz, aw, wh, pfl, fl, c);
|
||||
const float chr = 0.f;
|
||||
const float pow1 = pow_F(1.64f - pow_F(0.29f, n), 0.73f);
|
||||
float nj, nbbj, ncbj, czj, awj, flj;
|
||||
Ciecam02::initcam2float(gamu, yb2, pilotout, f2, la2, xw2, yw2, zw2, nj, dj, nbbj, ncbj, czj, awj, flj);
|
||||
const float reccmcz = 1.f / (c2 * czj);
|
||||
const float pow1n = pow_F(1.64f - pow_F(0.29f, nj), 0.73f);
|
||||
const float QproFactor = (0.4f / c) * (aw + 4.0f) ;
|
||||
const bool LabPassOne = true;
|
||||
|
||||
#ifdef __SSE2__
|
||||
int bufferLength = ((width + 3) / 4) * 4; // bufferLength has to be a multiple of 4
|
||||
#endif
|
||||
#ifndef _DEBUG
|
||||
#pragma omp parallel
|
||||
#endif
|
||||
{
|
||||
#ifdef __SSE2__
|
||||
// one line buffer per channel and thread
|
||||
float Jbuffer[bufferLength] ALIGNED16;
|
||||
float Cbuffer[bufferLength] ALIGNED16;
|
||||
float hbuffer[bufferLength] ALIGNED16;
|
||||
float Qbuffer[bufferLength] ALIGNED16;
|
||||
float Mbuffer[bufferLength] ALIGNED16;
|
||||
float sbuffer[bufferLength] ALIGNED16;
|
||||
#endif
|
||||
#ifndef _DEBUG
|
||||
#pragma omp for schedule(dynamic, 16)
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < height; i++) {
|
||||
#ifdef __SSE2__
|
||||
// vectorized conversion from Lab to jchqms
|
||||
int k;
|
||||
vfloat x, y, z;
|
||||
vfloat J, C, h, Q, M, s;
|
||||
|
||||
vfloat c655d35 = F2V(655.35f);
|
||||
|
||||
for (k = 0; k < width - 3; k += 4) {
|
||||
Color::Lab2XYZ(LVFU(lab->L[i][k]), LVFU(lab->a[i][k]), LVFU(lab->b[i][k]), x, y, z);
|
||||
x = x / c655d35;
|
||||
y = y / c655d35;
|
||||
z = z / c655d35;
|
||||
Ciecam02::xyz2jchqms_ciecam02float(J, C, h,
|
||||
Q, M, s, F2V(aw), F2V(fl), F2V(wh),
|
||||
x, y, z,
|
||||
F2V(xw1), F2V(yw1), F2V(zw1),
|
||||
F2V(c), F2V(nc), F2V(pow1), F2V(nbb), F2V(ncb), F2V(pfl), F2V(cz), F2V(d));
|
||||
STVF(Jbuffer[k], J);
|
||||
STVF(Cbuffer[k], C);
|
||||
STVF(hbuffer[k], h);
|
||||
STVF(Qbuffer[k], Q);
|
||||
STVF(Mbuffer[k], M);
|
||||
STVF(sbuffer[k], s);
|
||||
}
|
||||
|
||||
for (; k < width; k++) {
|
||||
float L = lab->L[i][k];
|
||||
float a = lab->a[i][k];
|
||||
float b = lab->b[i][k];
|
||||
float x, y, z;
|
||||
//convert Lab => XYZ
|
||||
Color::Lab2XYZ(L, a, b, x, y, z);
|
||||
x = x / 655.35f;
|
||||
y = y / 655.35f;
|
||||
z = z / 655.35f;
|
||||
float J, C, h, Q, M, s;
|
||||
Ciecam02::xyz2jchqms_ciecam02float(J, C, h,
|
||||
Q, M, s, aw, fl, wh,
|
||||
x, y, z,
|
||||
xw1, yw1, zw1,
|
||||
c, nc, gamu, pow1, nbb, ncb, pfl, cz, d);
|
||||
Jbuffer[k] = J;
|
||||
Cbuffer[k] = C;
|
||||
hbuffer[k] = h;
|
||||
Qbuffer[k] = Q;
|
||||
Mbuffer[k] = M;
|
||||
sbuffer[k] = s;
|
||||
}
|
||||
|
||||
#endif // __SSE2__
|
||||
|
||||
for (int j = 0; j < width; j++) {
|
||||
float J, C, h, Q, M, s;
|
||||
|
||||
#ifdef __SSE2__
|
||||
// use precomputed values from above
|
||||
J = Jbuffer[j];
|
||||
C = Cbuffer[j];
|
||||
h = hbuffer[j];
|
||||
Q = Qbuffer[j];
|
||||
M = Mbuffer[j];
|
||||
s = sbuffer[j];
|
||||
#else
|
||||
float x, y, z;
|
||||
float L = lab->L[i][j];
|
||||
float a = lab->a[i][j];
|
||||
float b = lab->b[i][j];
|
||||
float x1, y1, z1;
|
||||
//convert Lab => XYZ
|
||||
Color::Lab2XYZ(L, a, b, x1, y1, z1);
|
||||
x = (float)x1 / 655.35f;
|
||||
y = (float)y1 / 655.35f;
|
||||
z = (float)z1 / 655.35f;
|
||||
//process source==> normal
|
||||
Ciecam02::xyz2jchqms_ciecam02float(J, C, h,
|
||||
Q, M, s, aw, fl, wh,
|
||||
x, y, z,
|
||||
xw1, yw1, zw1,
|
||||
c, nc, gamu, pow1, nbb, ncb, pfl, cz, d);
|
||||
#endif
|
||||
float Jpro, Cpro, hpro, Qpro, Mpro, spro;
|
||||
Jpro = J;
|
||||
Cpro = C;
|
||||
hpro = h;
|
||||
Qpro = Q;
|
||||
Mpro = M;
|
||||
spro = s;
|
||||
|
||||
// we cannot have all algorithms with all chroma curves
|
||||
if (alg == 0) {
|
||||
// Jpro = CAMBrightCurveJ[Jpro * 327.68f]; //lightness CIECAM02 + contrast
|
||||
Qpro = QproFactor * sqrtf(Jpro);
|
||||
float Cp = (spro * spro * Qpro) / (1000000.f);
|
||||
Cpro = Cp * 100.f;
|
||||
float sres;
|
||||
Ciecam02::curvecolorfloat(chr, Cp, sres, 1.8f);
|
||||
Color::skinredfloat(Jpro, hpro, sres, Cp, 55.f, 30.f, 1, rstprotection, 100.f, Cpro);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//retrieve values C,J...s
|
||||
C = Cpro;
|
||||
J = Jpro;
|
||||
Q = Qpro;
|
||||
M = Mpro;
|
||||
h = hpro;
|
||||
s = spro;
|
||||
|
||||
if (LabPassOne) {
|
||||
#ifdef __SSE2__
|
||||
// write to line buffers
|
||||
Jbuffer[j] = J;
|
||||
Cbuffer[j] = C;
|
||||
hbuffer[j] = h;
|
||||
#else
|
||||
float xx, yy, zz;
|
||||
//process normal==> viewing
|
||||
|
||||
Ciecam02::jch2xyz_ciecam02float(xx, yy, zz,
|
||||
J, C, h,
|
||||
xw2, yw2, zw2,
|
||||
f2, c2, nc2, gamu, pow1n, nbbj, ncbj, flj, czj, dj, awj);
|
||||
float x, y, z;
|
||||
x = xx * 655.35f;
|
||||
y = yy * 655.35f;
|
||||
z = zz * 655.35f;
|
||||
float Ll, aa, bb;
|
||||
//convert xyz=>lab
|
||||
Color::XYZ2Lab(x, y, z, Ll, aa, bb);
|
||||
dest->L[i][j] = Ll;
|
||||
dest->a[i][j] = aa;
|
||||
dest->b[i][j] = bb;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
#ifdef __SSE2__
|
||||
// process line buffers
|
||||
float *xbuffer = Qbuffer;
|
||||
float *ybuffer = Mbuffer;
|
||||
float *zbuffer = sbuffer;
|
||||
|
||||
for (k = 0; k < bufferLength; k += 4) {
|
||||
Ciecam02::jch2xyz_ciecam02float(x, y, z,
|
||||
LVF(Jbuffer[k]), LVF(Cbuffer[k]), LVF(hbuffer[k]),
|
||||
F2V(xw2), F2V(yw2), F2V(zw2),
|
||||
F2V(nc2), F2V(pow1n), F2V(nbbj), F2V(ncbj), F2V(flj), F2V(dj), F2V(awj), F2V(reccmcz));
|
||||
STVF(xbuffer[k], x * c655d35);
|
||||
STVF(ybuffer[k], y * c655d35);
|
||||
STVF(zbuffer[k], z * c655d35);
|
||||
}
|
||||
|
||||
// XYZ2Lab uses a lookup table. The function behind that lut is a cube root.
|
||||
// SSE can't beat the speed of that lut, so it doesn't make sense to use SSE
|
||||
for (int j = 0; j < width; j++) {
|
||||
float Ll, aa, bb;
|
||||
//convert xyz=>lab
|
||||
Color::XYZ2Lab(xbuffer[j], ybuffer[j], zbuffer[j], Ll, aa, bb);
|
||||
|
||||
dest->L[i][j] = Ll;
|
||||
dest->a[i][j] = aa;
|
||||
dest->b[i][j] = bb;
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
//#ifdef _DEBUG
|
||||
|
||||
if (settings->verbose) {
|
||||
t2e.set();
|
||||
printf("CIECAM local 02 performed in %d usec:\n", t2e.etime(t1e));
|
||||
}
|
||||
|
||||
//#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void ImProcFunctions::vibrancelocal(int bfw, int bfh, LabImage* lab, LabImage* dest, bool & localskutili, LUTf & sklocalcurve)
|
||||
{
|
||||
if (!params->locallab.expvibrance) {
|
||||
@@ -5176,7 +5468,7 @@ void ImProcFunctions::Expose_Local(int sen, float **buflight, float **bufchro, c
|
||||
}
|
||||
|
||||
|
||||
void ImProcFunctions::ColorLight_Local(int call, LabImage * bufcolorig, float ** buflight, float ** bufchro, float ** bufchroslid, float ** bufhh, float ** buflightslid, bool &LHutili, bool &HHutili, const float hueplus, const float huemoins, const float hueref, const float dhue, const float chromaref, const float lumaref, LUTf & lllocalcurve, const LocLHCurve & loclhCurve, const LocHHCurve & lochhCurve, const local_params & lp, LabImage * original, LabImage * transformed, int cx, int cy)
|
||||
void ImProcFunctions::ColorLight_Local(int call, LabImage * bufcolorig, float ** buflightcat, float **buf_a_cat, float **buf_b_cat, float ** buflight, float ** bufchro, float ** bufchroslid, float ** bufhh, float ** buflightslid, bool &LHutili, bool &HHutili, const float hueplus, const float huemoins, const float hueref, const float dhue, const float chromaref, const float lumaref, LUTf & lllocalcurve, const LocLHCurve & loclhCurve, const LocHHCurve & lochhCurve, const local_params & lp, LabImage * original, LabImage * transformed, int cx, int cy)
|
||||
{
|
||||
BENCHFUN
|
||||
// chroma and lightness
|
||||
@@ -8111,7 +8403,7 @@ void ImProcFunctions::Lab_Local(int call, float** shbuffer, LabImage * original,
|
||||
|
||||
//local color and light
|
||||
|
||||
if (!lp.inv && (lp.chro != 0 || lp.ligh != 0.f || lp.qualcurvemet != 0) && lp.colorena) { // || lllocalcurve)) { //interior ellipse renforced lightness and chroma //locallutili
|
||||
if (!lp.inv && (lp.chro != 0 || lp.ligh != 0.f || lp.qualcurvemet != 0 || lp.war != 0) && lp.colorena) { // || lllocalcurve)) { //interior ellipse renforced lightness and chroma //locallutili
|
||||
// double huerefspot = 0., chromarefspot = 0., lumarefspot = 0.;
|
||||
// int spotSi = 1 + 2 * max (1, lp.cir / sk);
|
||||
/*
|
||||
@@ -8150,6 +8442,10 @@ void ImProcFunctions::Lab_Local(int call, float** shbuffer, LabImage * original,
|
||||
}
|
||||
|
||||
LabImage *bufcolorig = nullptr;
|
||||
CieImage *ncie = nullptr;
|
||||
LabImage *bufcat02 = nullptr;
|
||||
LabImage *bufcat02fin = nullptr;
|
||||
|
||||
float chpro = 1.f;
|
||||
float cligh = 1.f;
|
||||
float clighL = 1.f;
|
||||
@@ -8162,7 +8458,9 @@ void ImProcFunctions::Lab_Local(int call, float** shbuffer, LabImage * original,
|
||||
const JaggedArray<float> buflightslid(bfw, bfh);
|
||||
const JaggedArray<float> bufchroslid(bfw, bfh);
|
||||
const JaggedArray<float> bufhh(bfw, bfh);
|
||||
|
||||
const JaggedArray<float> buflightcat(bfw, bfh, true);
|
||||
const JaggedArray<float> buf_a_cat(bfw, bfh, true);
|
||||
const JaggedArray<float> buf_b_cat(bfw, bfh, true);
|
||||
|
||||
float adjustr = 1.0f;
|
||||
|
||||
@@ -8188,6 +8486,9 @@ void ImProcFunctions::Lab_Local(int call, float** shbuffer, LabImage * original,
|
||||
|
||||
if (call <= 3) { //simpleprocess, dcrop, improccoordinator
|
||||
bufcolorig = new LabImage(bfw, bfh); //buffer for data in zone limit
|
||||
ncie = new CieImage(bfw, bfh);
|
||||
bufcat02 = new LabImage(bfw, bfh); //buffer for data in zone limit
|
||||
bufcat02fin = new LabImage(bfw, bfh); //buffer for data in zone limit
|
||||
|
||||
|
||||
|
||||
@@ -8200,6 +8501,12 @@ void ImProcFunctions::Lab_Local(int call, float** shbuffer, LabImage * original,
|
||||
bufcolorig->L[ir][jr] = 0.f;
|
||||
bufcolorig->a[ir][jr] = 0.f;
|
||||
bufcolorig->b[ir][jr] = 0.f;
|
||||
bufcat02->L[ir][jr] = 0.f;
|
||||
bufcat02->a[ir][jr] = 0.f;
|
||||
bufcat02->b[ir][jr] = 0.f;
|
||||
bufcat02fin->L[ir][jr] = 0.f;
|
||||
bufcat02fin->a[ir][jr] = 0.f;
|
||||
bufcat02fin->b[ir][jr] = 0.f;
|
||||
bufchro[ir][jr] = 0.f;
|
||||
bufchroslid[ir][jr] = 0.f;
|
||||
buflightslid[ir][jr] = 0.f;
|
||||
@@ -8298,9 +8605,9 @@ void ImProcFunctions::Lab_Local(int call, float** shbuffer, LabImage * original,
|
||||
// int u = x - xb;
|
||||
|
||||
if (lox >= begx && lox < xEn && loy >= begy && loy < yEn) {
|
||||
bufcolorig->L[loy - begy][lox - begx] = original->L[y][x];//fill square buffer with datas
|
||||
bufcolorig->a[loy - begy][lox - begx] = original->a[y][x];//fill square buffer with datas
|
||||
bufcolorig->b[loy - begy][lox - begx] = original->b[y][x];//fill square buffer with datas
|
||||
bufcolorig->L[loy - begy][lox - begx] = bufcat02->L[loy - begy][lox - begx] = original->L[y][x];//fill square buffer with datas
|
||||
bufcolorig->a[loy - begy][lox - begx] = bufcat02->a[loy - begy][lox - begx] = original->a[y][x];//fill square buffer with datas
|
||||
bufcolorig->b[loy - begy][lox - begx] = bufcat02->b[loy - begy][lox - begx] = original->b[y][x];//fill square buffer with datas
|
||||
chpro = 0.f;
|
||||
|
||||
//Chroma curve
|
||||
@@ -8322,6 +8629,7 @@ void ImProcFunctions::Lab_Local(int call, float** shbuffer, LabImage * original,
|
||||
|
||||
chpro = 0.f;
|
||||
|
||||
|
||||
if (lp.chro != 0.f && lp.curvact) {
|
||||
// process to improve eg same as in Lab adjustements
|
||||
// float chromat = sqrt(SQR(bufcolorig->a[loy - begy][lox - begx]) + SQR(bufcolorig->b[loy - begy][lox - begx]));
|
||||
@@ -8391,14 +8699,22 @@ void ImProcFunctions::Lab_Local(int call, float** shbuffer, LabImage * original,
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (lp.war != 0) {
|
||||
// ImProcFunctions::ciecamloc_02float(ncie, bufcat02, bufcat02fin);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
ColorLight_Local(call, bufcolorig, buflight, bufchro, bufchroslid, bufhh, buflightslid, LHutili, HHutili, hueplus, huemoins, hueref, dhue, chromaref, lumaref, lllocalcurve, loclhCurve, lochhCurve, lp, original, transformed, cx, cy);
|
||||
ColorLight_Local(call, bufcolorig, buflightcat, buf_a_cat, buf_b_cat, buflight, bufchro, bufchroslid, bufhh, buflightslid, LHutili, HHutili, hueplus, huemoins, hueref, dhue, chromaref, lumaref, lllocalcurve, loclhCurve, lochhCurve, lp, original, transformed, cx, cy);
|
||||
|
||||
if (call <= 3) {
|
||||
|
||||
delete bufcolorig;
|
||||
delete ncie;
|
||||
delete bufcat02;
|
||||
|
||||
// delete bufcoltra;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user