From db6a8237afa4449ea425294ed22aabba48a7ef17 Mon Sep 17 00:00:00 2001 From: Emil Martinec Date: Mon, 10 Jan 2011 20:28:56 -0600 Subject: [PATCH] Restoring histograms to curves tools. --- rtengine/curves.cc | 2 +- rtengine/improccoordinator.cc | 27 +++++++++++++++++++-------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/rtengine/curves.cc b/rtengine/curves.cc index b200d2288..7ea17d99a 100644 --- a/rtengine/curves.cc +++ b/rtengine/curves.cc @@ -580,7 +580,7 @@ double CurveFactory::centercontrast (double x, double b, double m) { // apply custom/parametric/NURBS curve, if any if (tcurve) { if (outBeforeCCurveHistogram) { - float hval = dcurve[(int)shCurve[(int)(hlCurve[i])]]; + float hval = dcurve[(int)shCurve[CLIP((int)(hlCurve[i]*i))]]; //if (needigamma) // hval = igamma2 (hval); int hi = (int)(255.0*CLIPD(hval)); diff --git a/rtengine/improccoordinator.cc b/rtengine/improccoordinator.cc index c73a6bdff..513f67c54 100644 --- a/rtengine/improccoordinator.cc +++ b/rtengine/improccoordinator.cc @@ -53,7 +53,7 @@ ImProcCoordinator::ImProcCoordinator () Lhist = new unsigned int[256]; bcrgbhist = new unsigned int[256]; bcLhist = new unsigned int[256]; - bcabhist = new unsigned int[256]; + //bcabhist = new unsigned int[256]; } @@ -94,7 +94,7 @@ ImProcCoordinator::~ImProcCoordinator () { delete [] Lhist; delete [] bcrgbhist; delete [] bcLhist; - delete [] bcabhist; + //delete [] bcabhist; imgsrc->decreaseRef (); updaterThreadStart.unlock (); @@ -203,7 +203,11 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) { progress ("Exposure curve & CIELAB conversion...",100*readyphase/numofphases); if (todo & M_RGBCURVE) { - CurveFactory::complexCurve (params.toneCurve.expcomp, params.toneCurve.black/65535.0, params.toneCurve.hlcompr, params.toneCurve.hlcomprthresh, params.toneCurve.shcompr, params.toneCurve.brightness, params.toneCurve.contrast, imgsrc->getDefGain(), imgsrc->getGamma(), true, params.toneCurve.curve, vhist16, hltonecurve, shtonecurve, tonecurve, bcrgbhist, scale==1 ? 1 : 1); + CurveFactory::complexCurve (params.toneCurve.expcomp, params.toneCurve.black/65535.0, \ + params.toneCurve.hlcompr, params.toneCurve.hlcomprthresh, \ + params.toneCurve.shcompr, params.toneCurve.brightness, params.toneCurve.contrast, \ + imgsrc->getDefGain(), imgsrc->getGamma(), true, params.toneCurve.curve, vhist16, \ + hltonecurve, shtonecurve, tonecurve, bcrgbhist, scale==1 ? 1 : 1); ipf.rgbProc (oprevi, oprevl, hltonecurve, shtonecurve, tonecurve, shmap, params.toneCurve.saturation); // recompute luminance histogram @@ -215,7 +219,8 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) { readyphase++; if (todo & M_LUMACURVE) { - CurveFactory::complexCurve (0.0, 0.0, 0.0, 0.0, 0.0, params.labCurve.brightness, params.labCurve.contrast, 0.0, 0.0, false, params.labCurve.lcurve, lhist16, dummy1, dummy2, lumacurve, bcLhist, scale==1 ? 1 : 16); + CurveFactory::complexCurve (0.0, 0.0, 0.0, 0.0, 0.0, params.labCurve.brightness, params.labCurve.contrast, 0.0, 0.0, false, \ + params.labCurve.lcurve, lhist16, dummy1, dummy2, lumacurve, bcLhist, scale==1 ? 1 : 16); CurveFactory::complexsgnCurve (0.0, 100.0, params.labCurve.saturation, 1.0, params.labCurve.acurve, chroma_acurve, scale==1 ? 1 : 16); CurveFactory::complexsgnCurve (0.0, 100.0, params.labCurve.saturation, 1.0, params.labCurve.bcurve, chroma_bcurve, scale==1 ? 1 : 16); } @@ -402,13 +407,19 @@ void ImProcCoordinator::updateHistograms (int x1, int y1, int x2, int y2) { memset (rhist, 0, 256*sizeof(int)); memset (ghist, 0, 256*sizeof(int)); memset (bhist, 0, 256*sizeof(int)); - + memset (bcrgbhist, 0, 256*sizeof(int)); + for (int i=y1; idata[ofs++]]++; - ghist[previmg->data[ofs++]]++; - bhist[previmg->data[ofs++]]++; + int r=previmg->data[ofs++]; + int g=previmg->data[ofs++]; + int b=previmg->data[ofs++]; + + bcrgbhist[(int)(0.299*r + 0.587*g + 0.114*b)]++; + rhist[r]++; + ghist[g]++; + bhist[b]++; } }