Fix for oversaturated colors artifacts (yellow mostly).

This commit is contained in:
Emil Martinec 2010-11-09 00:32:14 -06:00
parent f2e14e720f
commit a876935d37
8 changed files with 32 additions and 30 deletions

View File

@ -587,7 +587,7 @@ void CurveFactory::complexCurve (double ecomp, double black, double hlcompr, dou
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void CurveFactory::complexCurve (double ecomp, double black, double hlcompr, double shcompr, double br, double contr, double defmul, double gamma_, bool igamma, const std::vector<double>& curvePoints, unsigned int* histogram, int* hlCurve, int* shCurve, int* outCurve, unsigned int* outBeforeCCurveHistogram, int skip) {
void CurveFactory::complexCurve (double ecomp, double black, double hlcompr, double shcompr, double br, double contr, double defmul, double gamma_, bool igamma, const std::vector<double>& curvePoints, unsigned int* histogram, float* hlCurve, float* shCurve, int* outCurve, unsigned int* outBeforeCCurveHistogram, int skip) {
double def_mul = pow (2.0, defmul);
@ -732,7 +732,7 @@ void CurveFactory::complexCurve (double ecomp, double black, double hlcompr, dou
// apply custom/parametric/NURBS curve, if any
if (tcurve) {
if (outBeforeCCurveHistogram) {
double hval = brightcurve->getVal (shCurve[hlCurve[(int)val]]);
double hval = brightcurve->getVal ((int)shCurve[(int)hlCurve[(int)val]]);
//if (needigamma)
// hval = igamma2 (hval);
int hi = (int)(255.0*CLIPD(hval));
@ -769,7 +769,7 @@ void CurveFactory::complexCurve (double ecomp, double black, double hlcompr, dou
double avg = 0;
//double sqavg = 0;
for (int i=0; i<=0xffff; i++) {
avg += dcurve[shCurve[hlCurve[i]]] * histogram[i];
avg += dcurve[(int)shCurve[(int)hlCurve[i]]] * histogram[i];
//sqavg += dcurve[i]*dcurve[i] * histogram[i];
sum += histogram[i];
}

View File

@ -157,7 +157,7 @@ class CurveFactory {
public:
// static void updateCurve3 (int* curve, int* ohistogram, const std::vector<double>& cpoints, double defmul, double ecomp, int black, double hlcompr, double shcompr, double br, double contr, double gamma_, bool igamma, int skip=1);
static void complexCurve (double ecomp, double black, double hlcompr, double shcompr, double br, double contr, double defmul, double gamma_, bool igamma, const std::vector<double>& curvePoints, unsigned int* histogram, int* hlCurve, int* shCurve, int* outCurve, unsigned int* outBeforeCCurveHistogram, int skip=1);
static void complexCurve (double ecomp, double black, double hlcompr, double shcompr, double br, double contr, double defmul, double gamma_, bool igamma, const std::vector<double>& curvePoints, unsigned int* histogram, float* hlCurve, float* shCurve, int* outCurve, unsigned int* outBeforeCCurveHistogram, int skip=1);
static void complexsgnCurve (double satclip, double satcompr, double saturation, double colormult, const std::vector<double>& curvePoints, int* outCurve, int skip=1);
};

View File

@ -178,7 +178,7 @@ void ImProcCoordinator::updatePreviewImage (int todo, Crop* cropCall) {
readyphase++;
if (todo & M_LUMACURVE) {
CurveFactory::complexCurve (0.0, 0.0, 0.0, 0.0, params.labCurve.brightness, params.labCurve.contrast, 0.0, 0.0, false, params.labCurve.lcurve, lhist16, chroma_acurve, chroma_bcurve, lumacurve, bcLhist, scale==1 ? 1 : 16);
CurveFactory::complexCurve (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);
}

View File

@ -62,8 +62,10 @@ class ImProcCoordinator : public StagedImageProcessor {
void freeAll ();
int hltonecurve [65536];
int shtonecurve [65536];
float dummy1 [65536];
float dummy2 [65536];
float hltonecurve [65536];
float shtonecurve [65536];
int tonecurve [65536];
int lumacurve [65536];

View File

@ -245,7 +245,7 @@ void ImProcFunctions::firstAnalysis (Image16* original, const ProcParams* params
delete [] hist;
}
void ImProcFunctions::rgbProc (Image16* working, LabImage* lab, int* hltonecurve, int* shtonecurve, int* tonecurve, SHMap* shmap, int sat) {
void ImProcFunctions::rgbProc (Image16* working, LabImage* lab, float* hltonecurve, float* shtonecurve, int* tonecurve, SHMap* shmap, int sat) {
int h_th, s_th;
if (shmap) {
@ -321,16 +321,14 @@ void ImProcFunctions::rgbProc (Image16* working, LabImage* lab, int* hltonecurve
b = CLIP((int)(factor*b));
}
}
//float h, s, v;
//rgb2hsv(r,g,b,h,s,v);
//highlight tone curve
/*r = tonecurve[r];
g = tonecurve[g];
b = tonecurve[b];*/
//int Y = (int)(0.299*r + 0.587*g + 0.114*b);
//float tonefactor = (Y>0 ? (float)tonecurve1[Y]/Y : 1);
float rtonefactor = (r>0 ? (float)hltonecurve[r]/r : 1);
float gtonefactor = (g>0 ? (float)hltonecurve[g]/g : 1);
float btonefactor = (b>0 ? (float)hltonecurve[b]/b : 1);
//v = (float)hltonecurve[(int)(65535*v)]/65535;
float rtonefactor = (r>0 ? (float)hltonecurve[r]/r : (float)hltonecurve[1]);
float gtonefactor = (g>0 ? (float)hltonecurve[g]/g : (float)hltonecurve[1]);
float btonefactor = (b>0 ? (float)hltonecurve[b]/b : (float)hltonecurve[1]);
//float tonefactor = MIN(rtonefactor, MIN(gtonefactor,btonefactor));
float tonefactor = (rtonefactor+gtonefactor+btonefactor)/3;
//float tonefactor = (0.299*rtonefactor+0.587*gtonefactor+0.114*btonefactor);
@ -360,6 +358,8 @@ void ImProcFunctions::rgbProc (Image16* working, LabImage* lab, int* hltonecurve
}
hsv2rgb(h,s,v,r,g,b);
}
//hsv2rgb(h,s,v,r,g,b);
int x = (toxyz[0][0] * r + toxyz[1][0] * g + toxyz[2][0] * b) >> 15;
int y = (toxyz[0][1] * r + toxyz[1][1] * g + toxyz[2][1] * b) >> 15;

View File

@ -79,7 +79,7 @@ class ImProcFunctions {
bool needsTransform ();
void firstAnalysis (Image16* working, const ProcParams* params, unsigned int* vhist16, double gamma);
void rgbProc (Image16* working, LabImage* lab, int* hltonecurve, int* shtonecurve, int* tonecurve, SHMap* shmap, int sat);
void rgbProc (Image16* working, LabImage* lab, float* hltonecurve, float* shtonecurve, int* tonecurve, SHMap* shmap, int sat);
void luminanceCurve (LabImage* lold, LabImage* lnew, int* curve, int row_from, int row_to);
void chrominanceCurve (LabImage* lold, LabImage* lnew, int channel, int* curve, int row_from, int row_to);
void colorCurve (LabImage* lold, LabImage* lnew);

View File

@ -400,8 +400,8 @@ IImage8* Thumbnail::processImage (const procparams::ProcParams& params, int rhei
if (params.toneCurve.autoexp && aeHistogram)
ipf.getAutoExp (aeHistogram, aeHistCompression, logDefGain, params.toneCurve.clip, br, bl);
int* curve1 = new int [65536];
int* curve2 = new int [65536];
float* curve1 = new float [65536];
float* curve2 = new float [65536];
int* curve = new int [65536];
CurveFactory::complexCurve (br, bl/65535.0, params.toneCurve.hlcompr, params.toneCurve.shcompr, params.toneCurve.brightness, params.toneCurve.contrast, logDefGain, isRaw ? 2.2 : 0, true, params.toneCurve.curve, hist16, curve1, curve2, curve, NULL, 16);
@ -420,10 +420,10 @@ IImage8* Thumbnail::processImage (const procparams::ProcParams& params, int rhei
// luminance processing
CurveFactory::complexCurve (0.0, 0.0, 0.0, 0.0, params.labCurve.brightness, params.labCurve.contrast, 0.0, 0.0, false, params.labCurve.lcurve, hist16, curve1, curve2, curve, NULL, 16);
ipf.luminanceCurve (labView, labView, curve, 0, fh);
CurveFactory::complexsgnCurve (0.0, 100.0, params.labCurve.saturation, 1.0, params.labCurve.acurve, curve1, 16);
ipf.chrominanceCurve (labView, labView, 0, curve1, 0, fh);
CurveFactory::complexsgnCurve (0.0, 100.0, params.labCurve.saturation, 1.0, params.labCurve.bcurve, curve1, 16);
ipf.chrominanceCurve (labView, labView, 1, curve1, 0, fh);
CurveFactory::complexsgnCurve (0.0, 100.0, params.labCurve.saturation, 1.0, params.labCurve.acurve, curve, 16);
ipf.chrominanceCurve (labView, labView, 0, curve, 0, fh);
CurveFactory::complexsgnCurve (0.0, 100.0, params.labCurve.saturation, 1.0, params.labCurve.bcurve, curve, 16);
ipf.chrominanceCurve (labView, labView, 1, curve, 0, fh);
delete [] curve1;
delete [] curve2;

View File

@ -128,8 +128,8 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
ipf.getAutoExp (aehist, aehistcompr, imgsrc->getDefGain(), params.toneCurve.clip, br, bl);
}
int* curve1 = new int [65536];
int* curve2 = new int [65536];
float* curve1 = new float [65536];
float* curve2 = new float [65536];
int* curve = new int [65536];
CurveFactory::complexCurve (br, bl/65535.0, params.toneCurve.hlcompr, params.toneCurve.shcompr, params.toneCurve.brightness, params.toneCurve.contrast, imgsrc->getDefGain(), imgsrc->getGamma(), true, params.toneCurve.curve, hist16, curve1, curve2, curve, NULL);
@ -153,10 +153,10 @@ IImage16* processImage (ProcessingJob* pjob, int& errorCode, ProgressListener* p
// luminance processing
CurveFactory::complexCurve (0.0, 0.0, 0.0, 0.0, params.labCurve.brightness, params.labCurve.contrast, 0.0, 0.0, false, params.labCurve.lcurve, hist16, curve1, curve2, curve, NULL);
ipf.luminanceCurve (labView, labView, curve, 0, fh);
CurveFactory::complexsgnCurve (0.0, 100.0, params.labCurve.saturation, 1.0, params.labCurve.acurve, curve1, 1);
ipf.chrominanceCurve (labView, labView, 0, curve1, 0, fh);
CurveFactory::complexsgnCurve (0.0, 100.0, params.labCurve.saturation, 1.0, params.labCurve.bcurve, curve1, 1);
ipf.chrominanceCurve (labView, labView, 1, curve1, 0, fh);
CurveFactory::complexsgnCurve (0.0, 100.0, params.labCurve.saturation, 1.0, params.labCurve.acurve, curve, 1);
ipf.chrominanceCurve (labView, labView, 0, curve, 0, fh);
CurveFactory::complexsgnCurve (0.0, 100.0, params.labCurve.saturation, 1.0, params.labCurve.bcurve, curve, 1);
ipf.chrominanceCurve (labView, labView, 1, curve, 0, fh);
ipf.impulsedenoise (labView);
ipf.lumadenoise (labView, buffer);