From 2bfc41fd03fa633f08fbf1039849e555cd4975fa Mon Sep 17 00:00:00 2001 From: Desmis Date: Mon, 30 Apr 2018 17:41:04 +0200 Subject: [PATCH] replace type_rgb_16 by type_rgb_flt and change some settings --- rtengine/dcrop.cc | 5 ++-- rtengine/imagefloat.cc | 6 ++--- rtengine/improccoordinator.cc | 5 ++-- rtengine/improcfun.h | 2 +- rtengine/iplab2rgb.cc | 45 ++++++++++++++++++----------------- rtengine/simpleprocess.cc | 5 ++-- rtgui/icmpanel.cc | 4 ++-- 7 files changed, 35 insertions(+), 37 deletions(-) diff --git a/rtengine/dcrop.cc b/rtengine/dcrop.cc index f53482e11..21fa919a9 100644 --- a/rtengine/dcrop.cc +++ b/rtengine/dcrop.cc @@ -817,8 +817,7 @@ void Crop::update(int todo) //first put gamma TRC to 1 int cw = baseCrop->getWidth(); int ch = baseCrop->getHeight(); - Image16* readyImg0 = NULL; - // I used Image16 because Imagefloat does not work + Imagefloat* readyImg0 = NULL; double ga0, ga1, ga2, ga3, ga4, ga5, ga6; int mul = -5; @@ -838,7 +837,7 @@ void Crop::update(int todo) delete readyImg0; //adjust gamma TRC - Image16* readyImg = NULL; + Imagefloat* readyImg = NULL; gga = params.icm.gamm, ssl = params.icm.slop; mul = 5; readyImg = parent->ipf.workingtrc(baseCrop, cw, ch, mul, params.icm.working, gga, ssl, ga0, ga1, ga2, ga3, ga4, ga5, ga6); diff --git a/rtengine/imagefloat.cc b/rtengine/imagefloat.cc index 4aaeb3e24..bc720699d 100644 --- a/rtengine/imagefloat.cc +++ b/rtengine/imagefloat.cc @@ -524,9 +524,9 @@ void Imagefloat::ExecCMSTransform(cmsHTRANSFORM hTransform) float *p = pBuf.data, *pR = r(y), *pG = g(y), *pB = b(y); for (int x = 0; x < width; x++) { - *(p++) = *(pR++); - *(p++) = *(pG++); - *(p++) = *(pB++); + *(p++) = *(pR++)/ 65535.f; + *(p++) = *(pG++)/ 65535.f; + *(p++) = *(pB++)/ 65535.f; } cmsDoTransform (hTransform, pBuf.data, pBuf.data, width); diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc index c00931fd0..f63aff9bd 100644 --- a/rtengine/improccoordinator.cc +++ b/rtengine/improccoordinator.cc @@ -494,8 +494,7 @@ void ImProcCoordinator::updatePreviewImage(int todo, Crop* cropCall) int cw = oprevi->getWidth(); int ch = oprevi->getHeight(); // put gamma TRC to 1 - Image16* readyImg0 = NULL; - // I used Image16 because Imagefloat does not work + Imagefloat* readyImg0 = NULL; double ga0, ga1, ga2, ga3, ga4, ga5, ga6; int mul = -5; double gga = 2.4, ssl = 12.92; @@ -513,7 +512,7 @@ void ImProcCoordinator::updatePreviewImage(int todo, Crop* cropCall) delete readyImg0; //adjust TRC - Image16* readyImg = NULL; + Imagefloat* readyImg = NULL; gga = params.icm.gamm, ssl = params.icm.slop; mul = 5; readyImg = ipf.workingtrc(oprevi, cw, ch, mul, params.icm.working, gga, ssl, ga0, ga1, ga2, ga3, ga4, ga5, ga6); diff --git a/rtengine/improcfun.h b/rtengine/improcfun.h index 130cb410e..56dddf0ad 100644 --- a/rtengine/improcfun.h +++ b/rtengine/improcfun.h @@ -352,7 +352,7 @@ public: Image8* lab2rgb(LabImage* lab, int cx, int cy, int cw, int ch, const procparams::ColorManagementParams &icm, bool consider_histogram_settings = true); Imagefloat* lab2rgbOut(LabImage* lab, int cx, int cy, int cw, int ch, const procparams::ColorManagementParams &icm, GammaValues *ga = nullptr); // CieImage *ciec; - Image16* workingtrc(Imagefloat* working, int cw, int ch, int mul, Glib::ustring profi, double gampos, double slpos, double &ga0, double &ga1, double &ga2, double &ga3, double &ga4, double &ga5, double &ga6); + Imagefloat* workingtrc(Imagefloat* working, int cw, int ch, int mul, Glib::ustring profi, double gampos, double slpos, double &ga0, double &ga1, double &ga2, double &ga3, double &ga4, double &ga5, double &ga6); bool transCoord(int W, int H, int x, int y, int w, int h, int& xv, int& yv, int& wv, int& hv, double ascaleDef = -1, const LensCorrection *pLCPMap = nullptr); bool transCoord(int W, int H, const std::vector &src, std::vector &red, std::vector &green, std::vector &blue, double ascaleDef = -1, const LensCorrection *pLCPMap = nullptr); diff --git a/rtengine/iplab2rgb.cc b/rtengine/iplab2rgb.cc index cd54e790c..700437734 100644 --- a/rtengine/iplab2rgb.cc +++ b/rtengine/iplab2rgb.cc @@ -427,8 +427,7 @@ Imagefloat* ImProcFunctions::lab2rgbOut(LabImage* lab, int cx, int cy, int cw, i } -// I don't know why, but with Imagefloat process does not work...It is probably due to my bad skill ! -Image16* ImProcFunctions::workingtrc(Imagefloat* working, int cw, int ch, int mul, Glib::ustring profi, double gampos, double slpos, double &ga0, double &ga1, double &ga2, double &ga3, double &ga4, double &ga5, double &ga6) +Imagefloat* ImProcFunctions::workingtrc(Imagefloat* working, int cw, int ch, int mul, Glib::ustring profi, double gampos, double slpos, double &ga0, double &ga1, double &ga2, double &ga3, double &ga4, double &ga5, double &ga6) { TMatrix wprof; @@ -455,7 +454,7 @@ Image16* ImProcFunctions::workingtrc(Imagefloat* working, int cw, int ch, int mu } }; - Image16* image = new Image16(cw, ch); + Imagefloat* image = new Imagefloat(cw, ch); double pwr; double ts; @@ -565,14 +564,14 @@ Image16* ImProcFunctions::workingtrc(Imagefloat* working, int cw, int ch, int mu p[4] = 0.0366; p[5] = 0.0001; } else { - /* - p[0] = 0.7347; //default primaries + + p[0] = 0.7347; //default primaries always unused p[1] = 0.2653; p[2] = 0.1596; p[3] = 0.8404; p[4] = 0.0366; p[5] = 0.0001; - */ + } if (slpos == 0) { @@ -622,11 +621,12 @@ Image16* ImProcFunctions::workingtrc(Imagefloat* working, int cw, int ch, int mu float* rr = working->r(i); float* rg = working->g(i); float* rb = working->b(i); - - short* xa = (short*)image->r(i); - short* ya = (short*)image->g(i); - short* za = (short*)image->b(i); - + + float* xa = (float*)image->r(i); + float* ya = (float*)image->g(i); + float* za = (float*)image->b(i); + + for (int j = 0; j < cw; j++) { float r1 = rr[j]; float g1 = rg[j]; @@ -636,27 +636,28 @@ Image16* ImProcFunctions::workingtrc(Imagefloat* working, int cw, int ch, int mu float x_ = toxyz[0][0] * r1 + toxyz[0][1] * g1 + toxyz[0][2] * b1; float y_ = toxyz[1][0] * r1 + toxyz[1][1] * g1 + toxyz[1][2] * b1; float z_ = toxyz[2][0] * r1 + toxyz[2][1] * g1 + toxyz[2][2] * b1; - - xa[j] = CLIP((int) round(x_)) ; - ya[j] = CLIP((int) round(y_)); - za[j] = CLIP((int) round(z_)); + + + xa[j] = ( x_) ; + ya[j] = ( y_); + za[j] = ( z_); } } cmsUInt32Number flags = cmsFLAGS_NOOPTIMIZE | cmsFLAGS_NOCACHE; - cmsHPROFILE iprof = ICCStore::getInstance()->getXYZProfile(); - lcmsMutex->lock(); - cmsHTRANSFORM hTransform = cmsCreateTransform(iprof, TYPE_RGB_16, oprofdef, TYPE_RGB_16, params->icm.outputIntent, cmsFLAGS_NOOPTIMIZE | cmsFLAGS_NOCACHE); - // cmsHTRANSFORM hTransform = cmsCreateTransform(iprof, TYPE_RGB_FLT, oprofdef, TYPE_RGB_FLT, params->icm.outputIntent, flags); - lcmsMutex->unlock(); + lcmsMutex->lock(); + cmsHPROFILE iprof = ICCStore::getInstance()->getXYZProfile(); + // cmsHTRANSFORM hTransform = cmsCreateTransform(iprof, TYPE_RGB_16, oprofdef, TYPE_RGB_16, params->icm.outputIntent, cmsFLAGS_NOOPTIMIZE | cmsFLAGS_NOCACHE); + cmsHTRANSFORM hTransform = cmsCreateTransform(iprof, TYPE_RGB_FLT, oprofdef, TYPE_RGB_FLT, params->icm.outputIntent, flags); + lcmsMutex->unlock(); image->ExecCMSTransform(hTransform); + cmsDeleteTransform(hTransform); - - + image->normalizeFloatTo65535(); } diff --git a/rtengine/simpleprocess.cc b/rtengine/simpleprocess.cc index af6c6e391..1c48734e0 100644 --- a/rtengine/simpleprocess.cc +++ b/rtengine/simpleprocess.cc @@ -892,8 +892,7 @@ private: int cw = baseImg->getWidth(); int ch = baseImg->getHeight(); // put gamma TRC to 1 - Image16* readyImg0 = NULL; - //Imagefloat does not work + Imagefloat* readyImg0 = NULL; double ga0, ga1, ga2, ga3, ga4, ga5, ga6; int mul = -5; double gga = 2.4, ssl = 12.92; @@ -911,7 +910,7 @@ private: delete readyImg0; //adjust TRC - Image16* readyImg = NULL; + Imagefloat* readyImg = NULL; gga = params.icm.gamm, ssl = params.icm.slop; mul = 5; readyImg = ipf.workingtrc(baseImg, cw, ch, mul, params.icm.working, gga, ssl, ga0, ga1, ga2, ga3, ga4, ga5, ga6); diff --git a/rtgui/icmpanel.cc b/rtgui/icmpanel.cc index e5167581b..5768da56c 100644 --- a/rtgui/icmpanel.cc +++ b/rtgui/icmpanel.cc @@ -205,8 +205,8 @@ ICMPanel::ICMPanel() : FoldableToolPanel(this, "icm", M("TP_ICM_LABEL")), iuncha Gtk::VBox * gammaVBox = Gtk::manage(new Gtk::VBox()); gammaVBox->set_spacing(2); - gamm = Gtk::manage(new Adjuster(M("TP_GAMMAWORK_GAMMA"), 0.40, 8.0, 0.001, 2.4)); - slop = Gtk::manage(new Adjuster(M("TP_GAMMAWORK_SLOPE"), 0., 60., 0.01, 12.92)); + gamm = Gtk::manage(new Adjuster(M("TP_GAMMAWORK_GAMMA"), 0.40, 10.0, 0.001, 2.4)); + slop = Gtk::manage(new Adjuster(M("TP_GAMMAWORK_SLOPE"), 0., 80., 0.01, 12.92)); wVBox->pack_start(*gamm, Gtk::PACK_SHRINK); gamm->show();