diff --git a/rtengine/dcrop.cc b/rtengine/dcrop.cc index d96713c71..03fdbbdda 100644 --- a/rtengine/dcrop.cc +++ b/rtengine/dcrop.cc @@ -183,7 +183,8 @@ void Crop::update (int todo) { bool butili=true; bool ccutili=true; bool cclutili=true; - + + LUTu dummy; parent->ipf.chromiLuminanceCurve (1,labnCrop, labnCrop, parent->chroma_acurve, parent->chroma_bcurve, parent->satcurve, parent->lhskcurve, parent->lumacurve, utili, autili, butili, ccutili,cclutili, dummy); parent->ipf.vibrance (labnCrop); @@ -201,14 +202,36 @@ void Crop::update (int todo) { parent->ipf.dirpyrequalizer (labnCrop); } } + + if(params.colorappearance.enabled){ + float fnum = parent->imgsrc->getMetaData()->getFNumber ();// F number + float fiso = parent->imgsrc->getMetaData()->getISOSpeed () ;// ISO + float fspeed = parent->imgsrc->getMetaData()->getShutterSpeed () ;//speed + float fcomp = parent->imgsrc->getMetaData()->getExpComp ();//compensation + - + float adap2,adap; + double ada, ada2; + if(fnum < 0.3f || fiso < 5.f || fspeed < 0.00001f) {adap=adap=2000.f;ada=ada2=2000.;}//if no exif data or wrong + else { + float E_V = fcomp + log2 ((fnum*fnum) / fspeed / (fiso/100.f)); + float expo2= params.toneCurve.expcomp;// exposure compensation in tonecurve ==> direct EV + E_V += expo2; + float expo1;//exposure raw white point + expo1=log2(params.raw.expos);//log2 ==>linear to EV + E_V += expo1; + adap2 = adap= powf(2.f, E_V-3.f);//cd / m2 + ada=ada2=(double) adap; + //end calculation adaptation scene luminosity + } + int begh = 0, endh = labnCrop->H; bool execsharp=false; float d; double dd; if(skip==1) execsharp=true; - if(settings->ciecamfloat) {parent->ipf.ciecam_02float (cieCrop,begh, endh, 1,labnCrop, ¶ms,parent->customColCurve1,parent->customColCurve2,parent->customColCurve3, dummy, dummy, 5, 1,(float**)cbuffer, execsharp, d); + if(settings->ciecamfloat) {parent->ipf.ciecam_02float (cieCrop, adap, begh, endh, 1, 2,labnCrop, ¶ms,parent->customColCurve1,parent->customColCurve2,parent->customColCurve3, dummy, dummy, 5, 1,(float**)cbuffer, execsharp, d); + } + else {parent->ipf.ciecam_02 (cieCrop,ada, begh, endh, 1, 2, labnCrop, ¶ms,parent->customColCurve1,parent->customColCurve2,parent->customColCurve3, dummy, dummy, 5, 1,(float**)cbuffer, execsharp, dd);} } - else {parent->ipf.ciecam_02 (cieCrop,begh, endh, 1,labnCrop, ¶ms,parent->customColCurve1,parent->customColCurve2,parent->customColCurve3, dummy, dummy, 5, 1,(float**)cbuffer, execsharp, dd);} } // switch back to rgb parent->ipf.lab2monitorRgb (labnCrop, cropImg); diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc index 6a7f8c955..43d530e12 100644 --- a/rtengine/improccoordinator.cc +++ b/rtengine/improccoordinator.cc @@ -387,23 +387,6 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) { if (y>=y1 && y=x1 && xgetMetaData()->getFNumber ();// F number - float fiso = imgsrc->getMetaData()->getISOSpeed () ;// ISO - float fspeed = imgsrc->getMetaData()->getShutterSpeed () ;//speed - float fcomp = imgsrc->getMetaData()->getExpComp ();//compensation + - - float adap; - if(fnum < 0.3f || fiso < 5.f || fspeed < 0.00001f) adap=2000.f;//if no exif data or wrong - else { - float E_V = fcomp + log2 ((fnum*fnum) / fspeed / (fiso/100.f)); - float expo2= params.toneCurve.expcomp;// exposure compensation in tonecurve ==> direct EV - E_V += expo2; - float expo1;//exposure raw white point - expo1=log2(params.raw.expos);//log2 ==>linear to EV - E_V += expo1; - adap = powf(2.f, E_V-3.f);//cd / m2 - //end calculation adaptation scene luminosity - } CurveFactory::curveLightBrightColor ( params.colorappearance.curveMode, params.colorappearance.curve, params.colorappearance.curveMode2, params.colorappearance.curve2, @@ -415,6 +398,25 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) { customColCurve3, scale==1 ? 1 : 1); int Iterates=0; + if(params.colorappearance.enabled){ + float fnum = imgsrc->getMetaData()->getFNumber ();// F number + float fiso = imgsrc->getMetaData()->getISOSpeed () ;// ISO + float fspeed = imgsrc->getMetaData()->getShutterSpeed () ;//speed + float fcomp = imgsrc->getMetaData()->getExpComp ();//compensation + - + float adap2,adap; + double ada, ada2; + if(fnum < 0.3f || fiso < 5.f || fspeed < 0.00001f) {adap=adap=2000.f;ada=2000.;}//if no exif data or wrong + else { + float E_V = fcomp + log2 ((fnum*fnum) / fspeed / (fiso/100.f)); + float expo2= params.toneCurve.expcomp;// exposure compensation in tonecurve ==> direct EV + E_V += expo2; + float expo1;//exposure raw white point + expo1=log2(params.raw.expos);//log2 ==>linear to EV + E_V += expo1; + adap2 = adap= powf(2.f, E_V-3.f);//cd / m2 + ada=ada2=(double) adap; + //end calculation adaptation scene luminosity + } int begh=0; int endh=pH; float d; @@ -424,13 +426,13 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) { buffer[i] = new float[pW]; bool execsharp=false; if(scale==1) execsharp=true; - if(settings->ciecamfloat){ipf.ciecam_02float (ncie, begh, endh, pW, nprevl, ¶ms, customColCurve1,customColCurve2,customColCurve3, histLCAM, histCCAM, 5, 1, (float**)buffer, execsharp, d); + if(settings->ciecamfloat){ipf.ciecam_02float (ncie, adap, begh, endh, pW, 2, nprevl, ¶ms, customColCurve1,customColCurve2,customColCurve3, histLCAM, histCCAM, 5, 1, (float**)buffer, execsharp, d); if(params.colorappearance.autodegree && acListener && params.colorappearance.enabled) acListener->autoCamChanged(100.*(double)d); - if(params.colorappearance.autoadapscen && acListener && params.colorappearance.enabled) acListener->adapCamChanged(adap);//real value of adapt scene luminosity + if(params.colorappearance.autoadapscen && acListener && params.colorappearance.enabled) acListener->adapCamChanged(adap2);//real value of adapt scene luminosity } - else {ipf.ciecam_02 (ncie, begh, endh, pW, nprevl, ¶ms, customColCurve1,customColCurve2,customColCurve3, histLCAM, histCCAM, 5, 1, (float**)buffer, execsharp, dd); + else {ipf.ciecam_02 (ncie, ada, begh, endh, pW, 2, nprevl, ¶ms, customColCurve1,customColCurve2,customColCurve3, histLCAM, histCCAM, 5, 1, (float**)buffer, execsharp, dd); if(params.colorappearance.autodegree && acListener && params.colorappearance.enabled) acListener->autoCamChanged(100.*dd); - if(params.colorappearance.autoadapscen && acListener && params.colorappearance.enabled) acListener->adapCamChanged(adap); + if(params.colorappearance.autoadapscen && acListener && params.colorappearance.enabled) acListener->adapCamChanged(ada); } for (int i=0; ihasListener () && cropCall != crops[i] ) diff --git a/rtengine/improcfun.cc b/rtengine/improcfun.cc index 5901d7f2d..38d0d8644 100644 --- a/rtengine/improcfun.cc +++ b/rtengine/improcfun.cc @@ -237,7 +237,7 @@ void ImProcFunctions::firstAnalysis (Imagefloat* original, const ProcParams* par } // Copyright (c) 2012 Jacques Desmis -void ImProcFunctions::ciecam_02 (CieImage* ncie, int begh, int endh, int pW, LabImage* lab, const ProcParams* params , const ColorAppearance & customColCurve1, const ColorAppearance & customColCurve2,const ColorAppearance & customColCurve3, LUTu & histLCAM, LUTu & histCCAM, int Iterates, int scale, float** buffer, bool execsharp, double &d) +void ImProcFunctions::ciecam_02 (CieImage* ncie, double adap, int begh, int endh, int pW, int pwb, LabImage* lab, const ProcParams* params , const ColorAppearance & customColCurve1, const ColorAppearance & customColCurve2,const ColorAppearance & customColCurve3, LUTu & histLCAM, LUTu & histCCAM, int Iterates, int scale, float** buffer, bool execsharp, double &d) { if(params->colorappearance.enabled) { @@ -368,6 +368,10 @@ if(params->colorappearance.enabled) { //La and la2 = ambiant luminosity scene and viewing la=double(params->colorappearance.adapscen); + if(pwb==2){ + if(params->colorappearance.autoadapscen) la=adap; + } + la2=double(params->colorappearance.adaplum); // level of adaptation @@ -1046,7 +1050,7 @@ if((params->colorappearance.tonecie || (params->colorappearance.tonecie && param // Copyright (c) 2012 Jacques Desmis -void ImProcFunctions::ciecam_02float (CieImage* ncie, int begh, int endh, int pW, LabImage* lab, const ProcParams* params , const ColorAppearance & customColCurve1, const ColorAppearance & customColCurve2,const ColorAppearance & customColCurve3, LUTu & histLCAM, LUTu & histCCAM, int Iterates, int scale, float** buffer, bool execsharp, float &d) +void ImProcFunctions::ciecam_02float (CieImage* ncie, float adap, int begh, int endh, int pW, int pwb, LabImage* lab, const ProcParams* params , const ColorAppearance & customColCurve1, const ColorAppearance & customColCurve2,const ColorAppearance & customColCurve3, LUTu & histLCAM, LUTu & histCCAM, int Iterates, int scale, float** buffer, bool execsharp, float &d) { if(params->colorappearance.enabled) { //printf("ciecam float\n"); @@ -1070,6 +1074,7 @@ if(params->colorappearance.enabled) { LUTu hist16_CCAM(65536); bool chropC=false; float valc; + if(pW!=1){//only with improccoordinator for (int i=0; i<48000; i++) { //# 32768*1.414 approximation maxi for chroma valc = (double)i / 47999.0; @@ -1177,6 +1182,10 @@ if(params->colorappearance.enabled) { //La and la2 = ambiant luminosity scene and viewing la=float(params->colorappearance.adapscen); + if(pwb==2){ + if(params->colorappearance.autoadapscen) la=adap; + } + la2=float(params->colorappearance.adaplum); // level of adaptation diff --git a/rtengine/improcfun.h b/rtengine/improcfun.h index cd986069c..d9028719a 100644 --- a/rtengine/improcfun.h +++ b/rtengine/improcfun.h @@ -99,8 +99,8 @@ class ImProcFunctions { SHMap* shmap, int sat, LUTf & rCurve, LUTf & gCurve, LUTf & bCurve, const ToneCurve & customToneCurve1, const ToneCurve & customToneCurve2, double expcomp, int hlcompr, int hlcomprthresh); void luminanceCurve (LabImage* lold, LabImage* lnew, LUTf &curve); - void ciecam_02float (CieImage* ncie, int begh, int endh, int pW, LabImage* lab, const ProcParams* params , const ColorAppearance & customColCurve1, const ColorAppearance & customColCurve, const ColorAppearance & customColCurve3, LUTu &histLCAM, LUTu &histCCAM,int Iterates, int scale, float** buffer, bool execsharp, float &d); - void ciecam_02 (CieImage* ncie, int begh, int endh, int pW, LabImage* lab, const ProcParams* params , const ColorAppearance & customColCurve1, const ColorAppearance & customColCurve, const ColorAppearance & customColCurve3, LUTu &histLCAM, LUTu &histCCAM,int Iterates, int scale, float** buffer, bool execsharp, double &d); + void ciecam_02float (CieImage* ncie, float adap, int begh, int endh, int pW, int pwb, LabImage* lab, const ProcParams* params , const ColorAppearance & customColCurve1, const ColorAppearance & customColCurve, const ColorAppearance & customColCurve3, LUTu &histLCAM, LUTu &histCCAM,int Iterates, int scale, float** buffer, bool execsharp, float &d); + void ciecam_02 (CieImage* ncie, double adap, int begh, int endh, int pW, int pwb, LabImage* lab, const ProcParams* params , const ColorAppearance & customColCurve1, const ColorAppearance & customColCurve, const ColorAppearance & customColCurve3, LUTu &histLCAM, LUTu &histCCAM,int Iterates, int scale, float** buffer, bool execsharp, double &d); void chromiLuminanceCurve (int pW, LabImage* lold, LabImage* lnew, LUTf &acurve, LUTf &bcurve, LUTf & satcurve,LUTf & satclcurve, LUTf &curve, bool utili, bool autili, bool butili, bool ccutili, bool cclutili, LUTu &histCCurve); void vibrance (LabImage* lab);//Jacques' vibrance void colorCurve (LabImage* lold, LabImage* lnew); diff --git a/rtengine/rtthumbnail.cc b/rtengine/rtthumbnail.cc index db350acd8..ae52b32d9 100644 --- a/rtengine/rtthumbnail.cc +++ b/rtengine/rtthumbnail.cc @@ -52,7 +52,7 @@ Thumbnail* Thumbnail::loadFromImage (const Glib::ustring& fname, int &w, int &h, if (deg) { img->rotate(deg); } - + Thumbnail* tpp = new Thumbnail (); tpp->camwbRed = 1.0; @@ -557,7 +557,7 @@ IImage8* Thumbnail::quickProcessImage (const procparams::ProcParams& params, int // Full thumbnail processing, second stage if complete profile exists IImage8* Thumbnail::processImage (const procparams::ProcParams& params, int rheight, TypeInterpolation interp, std::string camName, - double focalLen, double focalLen35mm, float focusDist, double& myscale) { + double focalLen, double focalLen35mm, float focusDist, float shutter, float fnumber, float iso,std::string expcomp_, double& myscale) { // compute WB multipliers ColorTemp currWB = ColorTemp (params.wb.temperature, params.wb.green, params.wb.method); @@ -793,16 +793,40 @@ IImage8* Thumbnail::processImage (const procparams::ProcParams& params, int rhei 16); int f_h=2,f_w=2; + if(params.colorappearance.enabled){ float** buffer = new float*[fh]; for (int i=0; i direct EV + E_V += expo2; + float expo1;//exposure raw white point + expo1=log2(params.raw.expos);//log2 ==>linear to EV + E_V += expo1; + adap2 = adap= powf(2.f, E_V-3.f);//cd / m2 + ada=ada2=(double) adap; + //end calculation adaptation scene luminosity + } + + ipf.ciecam_02float (cieView, adap, begh, endh, 1, 2, labView, ¶ms,customColCurve1,customColCurve2,customColCurve3, dummy, dummy, 5, 6, (float**)buffer, execsharp, d); for (int i=0; igetMetaData()->getFNumber ();// F number + float fiso = imgsrc->getMetaData()->getISOSpeed () ;// ISO + float fspeed = imgsrc->getMetaData()->getShutterSpeed () ;//speed + float fcomp = imgsrc->getMetaData()->getExpComp ();//compensation + - + if(fnum < 0.3f || fiso < 5.f || fspeed < 0.00001f) {adap=adap2=2000.f;ada=ada2=2000.;}//if no exif data or wrong + else { + float E_V = fcomp + log2 ((fnum*fnum) / fspeed / (fiso/100.f)); + float expo2= params.toneCurve.expcomp;// exposure compensation in tonecurve ==> direct EV + E_V += expo2; + float expo1;//exposure raw white point + expo1=log2(params.raw.expos);//log2 ==>linear to EV + E_V += expo1; + adap2 = adap= powf(2.f, E_V-3.f);//cd / m2 + ada=ada2=(double) adap; + } if (params.sharpening.enabled) { float d; double dd; + float** buffer = new float*[fh]; for (int i=0; iciecamfloat) ipf.ciecam_02float (cieView, begh, endh,1, labView, ¶ms,customColCurve1,customColCurve2,customColCurve3, dummy, dummy, 5, 1, (float**)buffer, true, d); - else ipf.ciecam_02 (cieView, begh, endh,1, labView, ¶ms,customColCurve1,customColCurve2,customColCurve3, dummy, dummy, 5, 1, (float**)buffer, true, dd); + if(settings->ciecamfloat) ipf.ciecam_02float (cieView, adap, begh, endh,1,2, labView, ¶ms,customColCurve1,customColCurve2,customColCurve3, dummy, dummy, 5, 1, (float**)buffer, true, d); + else ipf.ciecam_02 (cieView, ada, begh, endh,1,2, labView, ¶ms,customColCurve1,customColCurve2,customColCurve3, dummy, dummy, 5, 1, (float**)buffer, true, dd); for (int i=0; iciecamfloat) ipf.ciecam_02float (cieView, begh, endh,1, labView, ¶ms,customColCurve1,customColCurve2,customColCurve3, dummy, dummy, 5, 1, (float**)buffer, true, d); -else ipf.ciecam_02 (cieView, begh, endh,1, labView, ¶ms,customColCurve1,customColCurve2,customColCurve3, dummy, dummy, 5, 1, (float**)buffer, true, dd); +if(settings->ciecamfloat) ipf.ciecam_02float (cieView, adap, begh, endh,1,2, labView, ¶ms,customColCurve1,customColCurve2,customColCurve3, dummy, dummy, 5, 1, (float**)buffer, true, d); +else ipf.ciecam_02 (cieView, adap, begh, endh,1, 2, labView, ¶ms,customColCurve1,customColCurve2,customColCurve3, dummy, dummy, 5, 1, (float**)buffer, true, dd); for (int i=0; iprocParamsChanged (this, whoChangedIt); } @@ -313,7 +313,7 @@ void Thumbnail::clearProcParams (int whoClearedIt) { safe_g_remove (fname_); } - for (size_t i=0; iprocParamsChanged (this, whoClearedIt); } @@ -355,7 +355,7 @@ void Thumbnail::setProcParams (const ProcParams& pp, ParamsEdited* pe, int whoCh if (updateCacheNow) updateCache (); - for (size_t i=0; iprocParamsChanged (this, whoChangedIt); } @@ -463,9 +463,9 @@ rtengine::IImage8* Thumbnail::processThumbImage (const rtengine::procparams::Pro else { // Full thumbnail: apply profile - image = tpp->processImage (pparams, h, rtengine::TI_Bilinear, cfs.camera, cfs.focalLen, cfs.focalLen35mm, cfs.focusDist, scale ); + image = tpp->processImage (pparams, h, rtengine::TI_Bilinear, cfs.camera, cfs.focalLen, cfs.focalLen35mm, cfs.focusDist, cfs.shutter, cfs.fnumber, cfs.iso, cfs.expcomp, scale ); } - + tpp->getDimensions(lastW,lastH,lastScale); delete tpp; @@ -488,7 +488,7 @@ rtengine::IImage8* Thumbnail::upgradeThumbImage (const rtengine::procparams::Pro return 0; } - rtengine::IImage8* image = tpp->processImage (pparams, h, rtengine::TI_Bilinear, cfs.camera, cfs.focalLen, cfs.focalLen35mm, cfs.focusDist, scale ); + rtengine::IImage8* image = tpp->processImage (pparams, h, rtengine::TI_Bilinear, cfs.camera, cfs.focalLen, cfs.focalLen35mm, cfs.focusDist,cfs.shutter, cfs.fnumber, cfs.iso, cfs.expcomp, scale ); tpp->getDimensions(lastW,lastH,lastScale); delete tpp; @@ -508,11 +508,10 @@ void Thumbnail::generateExifDateTimeStrings () { if (options.fbShowExpComp && cfs.expcomp!="0.00" && cfs.expcomp!="") // don't show exposure compensation if it is 0.00EV;old cache iles do not have ExpComp, so value will not be displayed. exifString = Glib::ustring::compose ("%1 %2EV", exifString, cfs.expcomp); // append exposure compensation to exifString - std::string dateFormat = options.dateFormat; std::ostringstream ostr; bool spec = false; - for (size_t i=0; ihasExif()) { cfs.shutter = idata->getShutterSpeed (); - cfs.fnumber = idata->getFNumber (); + cfs.fnumber = idata->getFNumber (); cfs.focalLen = idata->getFocalLen (); cfs.focalLen35mm = idata->getFocalLen35mm (); cfs.focusDist = idata->getFocusDist ();