diff --git a/rtengine/LUT.h b/rtengine/LUT.h index ca4ef64ea..ad43ab471 100644 --- a/rtengine/LUT.h +++ b/rtengine/LUT.h @@ -145,7 +145,7 @@ public: } // use with float indices T operator[](float index) { - int idx = floor(index); + int idx = (int)index; // don't use floor! The difference in negative space is no problems here if (((unsigned int)idx) > maxs) { if (idx<0) { diff --git a/rtengine/dcrop.cc b/rtengine/dcrop.cc index 717b3aff6..29b541eb5 100644 --- a/rtengine/dcrop.cc +++ b/rtengine/dcrop.cc @@ -182,9 +182,9 @@ void Crop::update (int todo) { } // switch back to rgb - parent->ipf.lab2rgb (labnCrop, cropImg); + parent->ipf.lab2monitorRgb (labnCrop, cropImg); - //parent->ipf.lab2rgb (laboCrop, cropImg); + //parent->ipf.lab2monitorRgb (laboCrop, cropImg); //cropImg = baseCrop->to8(); /* diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc index fba4ce1d3..65e66b974 100644 --- a/rtengine/improccoordinator.cc +++ b/rtengine/improccoordinator.cc @@ -335,7 +335,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) { previmg->getMutex().lock(); try { - ipf.lab2rgb (nprevl, previmg); + ipf.lab2monitorRgb (nprevl, previmg); delete workimg; workimg = ipf.lab2rgb (nprevl, 0,0,pW,pH, params.icm.working); } diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc index 7f9c005e2..b30f7cd1a 100644 --- a/rtengine/improcfun.cc +++ b/rtengine/improcfun.cc @@ -157,8 +157,8 @@ void ImProcFunctions::firstAnalysis (Imagefloat* original, const ProcParams* par if (monitor) { cmsHPROFILE iprof = iccStore->getXYZProfile (); lcmsMutex->lock (); - monitorTransform = cmsCreateTransform (iprof, TYPE_RGB_FLT, monitor, TYPE_RGB_8, settings->colorimetricIntent, - cmsFLAGS_NOOPTIMIZE | cmsFLAGS_NOCACHE ); // NOCACHE is important for thread safety + monitorTransform = cmsCreateTransform (iprof, TYPE_RGB_16, monitor, TYPE_RGB_8, settings->colorimetricIntent, + cmsFLAGS_NOOPTIMIZE | cmsFLAGS_NOCACHE ); // NOCACHE is for thread safety, NOOPTIMIZE for precision lcmsMutex->unlock (); } diff --git a/rtengine/improcfun.h b/rtengine/improcfun.h index 7f1650c69..07bb0db06 100644 --- a/rtengine/improcfun.h +++ b/rtengine/improcfun.h @@ -121,7 +121,7 @@ class ImProcFunctions { void colorCurve (LabImage* lold, LabImage* lnew); void sharpening (LabImage* lab, float** buffer); void transform (Imagefloat* original, Imagefloat* transformed, int cx, int cy, int sx, int sy, int oW, int oH); - void lab2rgb (LabImage* lab, Image8* image); + void lab2monitorRgb (LabImage* lab, Image8* image); void resize (Image16* src, Image16* dst, float dScale); void deconvsharpening (LabImage* lab, float** buffer); void MLsharpen (LabImage* lab);// Manuel's clarity / sharpening diff --git a/rtengine/iplab2rgb.cc b/rtengine/iplab2rgb.cc index d30c34879..2820b9362 100644 --- a/rtengine/iplab2rgb.cc +++ b/rtengine/iplab2rgb.cc @@ -54,7 +54,7 @@ const double (*iwprof[])[3] = {sRGB_xyz, adobe_xyz, prophoto_xyz, widegamut_xyz, const char* wprofnames[] = {"sRGB", "Adobe RGB", "ProPhoto", "WideGamut", "BruceRGB", "Beta RGB", "BestRGB"}; const int numprof = 7; -void ImProcFunctions::lab2rgb (LabImage* lab, Image8* image) { +void ImProcFunctions::lab2monitorRgb (LabImage* lab, Image8* image) { //MyTime tBeg,tEnd; // tBeg.set(); //gamutmap(lab); @@ -64,7 +64,8 @@ void ImProcFunctions::lab2rgb (LabImage* lab, Image8* image) { // cmsDoTransform is relatively expensive #pragma omp parallel for for (int i=0; iH; i++) { - float buffer[3*lab->W]; + // pre-conversion to integer, since the output is 8 bit anyway, but LCMS is MUCH faster not converting from float + unsigned short buffer[3*lab->W]; const int ix = i * 3 * lab->W; int iy = 0; @@ -85,9 +86,9 @@ void ImProcFunctions::lab2rgb (LabImage* lab, Image8* image) { y_ = f2xyz(fy); z_ = f2xyz(fz)*D50z; - buffer[iy++] = CLIP01(x_); - buffer[iy++] = CLIP01(y_); - buffer[iy++] = CLIP01(z_); + buffer[iy++] = (unsigned short)CLIP(x_* CMAXVAL+0.5); + buffer[iy++] = (unsigned short)CLIP(y_* CMAXVAL+0.5); + buffer[iy++] = (unsigned short)CLIP(z_* CMAXVAL+0.5); } cmsDoTransform (monitorTransform, buffer, image->data + ix, lab->W); @@ -174,9 +175,9 @@ Image8* ImProcFunctions::lab2rgb (LabImage* lab, int cx, int cy, int cw, int ch, float y_ = 65535.0 * f2xyz(fy); float z_ = 65535.0 * f2xyz(fz)*D50z; - buffer[iy++] = CLIP((int)x_); - buffer[iy++] = CLIP((int)y_); - buffer[iy++] = CLIP((int)z_); + buffer[iy++] = CLIP((int)(x_+0.5)); + buffer[iy++] = CLIP((int)(y_+0.5)); + buffer[iy++] = CLIP((int)(z_+0.5)); } cmsDoTransform (hTransform, buffer, image->data + ix, cw); @@ -258,9 +259,9 @@ Image16* ImProcFunctions::lab2rgb16 (LabImage* lab, int cx, int cy, int cw, int float y_ = 65535.0 * f2xyz(fy); float z_ = 65535.0 * f2xyz(fz)*D50z; - xa[j-cx] = CLIP((int)x_); - ya[j-cx] = CLIP((int)y_); - za[j-cx] = CLIP((int)z_); + xa[j-cx] = CLIP((int)(x_+0.5)); + ya[j-cx] = CLIP((int)(y_+0.5)); + za[j-cx] = CLIP((int)(z_+0.5)); } } diff --git a/rtengine/rtthumbnail.cc b/rtengine/rtthumbnail.cc index b2906c56b..5d033cff2 100644 --- a/rtengine/rtthumbnail.cc +++ b/rtengine/rtthumbnail.cc @@ -775,7 +775,7 @@ IImage8* Thumbnail::processImage (const procparams::ProcParams& params, int rhei // obtain final image Image8* readyImg = new Image8 (fw, fh); - ipf.lab2rgb (labView, readyImg); + ipf.lab2monitorRgb (labView, readyImg); delete labView; delete baseImg;