Fixes for auto-exposure, restoring histogram to curves, and labelling of colors in HSV equalizer.

This commit is contained in:
Emil Martinec
2010-11-13 15:41:08 -06:00
parent d0717b8b85
commit d6b59d7215
8 changed files with 34 additions and 23 deletions

View File

@@ -634,8 +634,8 @@ TP_HLREC_LABEL;Highlight Reconstruction
TP_HLREC_LUMINANCE;Luminance Recovery TP_HLREC_LUMINANCE;Luminance Recovery
TP_HLREC_METHOD;Method: TP_HLREC_METHOD;Method:
TP_HSVEQUALIZER1;Red TP_HSVEQUALIZER1;Red
TP_HSVEQUALIZER2;Orange TP_HSVEQUALIZER2;Yellow
TP_HSVEQUALIZER3;Yellow TP_HSVEQUALIZER3;Lime
TP_HSVEQUALIZER4;Green TP_HSVEQUALIZER4;Green
TP_HSVEQUALIZER5;Aqua TP_HSVEQUALIZER5;Aqua
TP_HSVEQUALIZER6;Blue TP_HSVEQUALIZER6;Blue

View File

@@ -4,7 +4,7 @@ Version=20101111
[Exposure] [Exposure]
Auto=true Auto=true
Clip=0.01 Clip=0.0001
Compensation=0 Compensation=0
Brightness=0 Brightness=0
Contrast=12 Contrast=12

View File

@@ -4,7 +4,7 @@ Version=20101111
[Exposure] [Exposure]
Auto=true Auto=true
Clip=0.01 Clip=0.0001
Compensation=0 Compensation=0
Brightness=0 Brightness=0
Contrast=0 Contrast=0

View File

@@ -1,10 +1,9 @@
[Version] [Version]
Version=20101111 Version=20101111
[Exposure] [Exposure]
Auto=false Auto=false
Clip=0.001 Clip=0.0001
Compensation=0 Compensation=0
Brightness=0 Brightness=0
Contrast=0 Contrast=0

View File

@@ -734,8 +734,7 @@ void CurveFactory::complexCurve (double ecomp, double black, double hlcompr, dou
// apply custom/parametric/NURBS curve, if any // apply custom/parametric/NURBS curve, if any
if (tcurve) { if (tcurve) {
if (outBeforeCCurveHistogram) { if (outBeforeCCurveHistogram) {
cum *= (float)val/val0; float hval = shCurve[(int)(hlCurve[i])]*(float)val/(65535*val0);
float hval = brightcurve->getVal (cum);
//if (needigamma) //if (needigamma)
// hval = igamma2 (hval); // hval = igamma2 (hval);
int hi = (int)(255.0*CLIPD(hval)); int hi = (int)(255.0*CLIPD(hval));

View File

@@ -389,6 +389,15 @@ void ImProcCoordinator::updateHistograms (int x1, int y1, int x2, int y2) {
for (int i=y1; i<y2; i++) for (int i=y1; i<y2; i++)
for (int j=x1; j<x2; j++) for (int j=x1; j<x2; j++)
Lhist[nprevl->L[i][j]/256]++; Lhist[nprevl->L[i][j]/256]++;
/*for (int i=0; i<256; i++) {
Lhist[i] = (int)(256*sqrt(Lhist[i]));
rhist[i] = (int)(256*sqrt(rhist[i]));
ghist[i] = (int)(256*sqrt(ghist[i]));
bhist[i] = (int)(256*sqrt(bhist[i]));
bcrgbhist[i] = (int)(256*sqrt(bcrgbhist[i]));
bcLhist[i] = (int)(256*sqrt(bcLhist[i]));
}*/
} }
void ImProcCoordinator::progress (Glib::ustring str, int pr) { void ImProcCoordinator::progress (Glib::ustring str, int pr) {

View File

@@ -615,7 +615,7 @@ void ImProcFunctions::getAutoExp (unsigned int* histogram, int histcompr, doubl
double corr = pow(2.0, expcomp); double corr = pow(2.0, expcomp);
// black point selection is based on the linear result (yielding better visual results) // black point selection is based on the linear result (yielding better visual results)
bl = (int)(shc /* * corr*/); bl = (int)(shc * corr);
// compute the white point of the exp. compensated gamma corrected image // compute the white point of the exp. compensated gamma corrected image
double awg = (int)(CurveFactory::gamma2 (aw * corr / 65536.0) * 65536.0); double awg = (int)(CurveFactory::gamma2 (aw * corr / 65536.0) * 65536.0);
@@ -624,17 +624,17 @@ void ImProcFunctions::getAutoExp (unsigned int* histogram, int histcompr, doubl
for (int i=0; i<65536>>histcompr; i++) for (int i=0; i<65536>>histcompr; i++)
gavg += histogram[i] * CurveFactory::gamma2((int)(corr*(i<<histcompr)<65535 ? corr*(i<<histcompr) : 65535)) / sum; gavg += histogram[i] * CurveFactory::gamma2((int)(corr*(i<<histcompr)<65535 ? corr*(i<<histcompr) : 65535)) / sum;
if (bl < gavg) { if (bl < gavg) {
int maxaw = (gavg - bl) * 4 / 3 + bl; // dont let aw be such large that the histogram average goes above 3/4 int maxaw = (gavg - bl) * 4 / 3 + bl; // dont let aw be such large that the histogram average goes above 3/4
double mavg = 65536.0 / (awg-bl) * (gavg - bl); //double mavg = 65536.0 / (awg-bl) * (gavg - bl);
if (awg < maxaw) if (awg < maxaw)
awg = maxaw; awg = maxaw;
} }
awg = CurveFactory::igamma2 ((float)(awg/65535.0)) * 65535.0; //need to inverse gamma transform to get correct exposure compensation parameter awg = CurveFactory::igamma2 ((float)(awg/65535.0)) * 65535.0; //need to inverse gamma transform to get correct exposure compensation parameter
br = log(65535.0 / (awg-bl)) / log(2.0); bl = (int)((65535*bl)/awg);
br = log(65535.0 / (awg)) / log(2.0);
if (br<0) if (br<0)
br = 0; br = 0;
} }

View File

@@ -2014,18 +2014,22 @@ int RawImageSource::getAEHistogram (unsigned int* histogram, int& histcompr) {
end = ri->width-border; end = ri->width-border;
} }
if (ri->filters) if (ri->filters)
for (int j=start; j<end; j++) for (int j=start; j<end; j++) {
/*if (ISGREEN(ri,i,j)) if (ISGREEN(ri,i,j))
histogram[rawData[i][j]>>histcompr]+=2; histogram[CLIP((int)(camwb_green*rawData[i][j]))>>histcompr]+=4;
else*/ else if (ISRED(ri,i,j))
histogram[rawData[i][j]>>histcompr]+=4; histogram[CLIP((int)(camwb_red*rawData[i][j]))>>histcompr]+=4;
else else if (ISBLUE(ri,i,j))
histogram[CLIP((int)(camwb_blue*rawData[i][j]))>>histcompr]+=4;
} else {
for (int j=start; j<3*end; j++) { for (int j=start; j<3*end; j++) {
histogram[rawData[i][j+0]>>histcompr]++; histogram[CLIP((int)(rawData[i][j+0]>>histcompr))]++;
histogram[rawData[i][j+1]>>histcompr]+=2; histogram[CLIP((int)(rawData[i][j+1]>>histcompr))]+=2;
histogram[rawData[i][j+2]>>histcompr]++; histogram[CLIP((int)(rawData[i][j+2]>>histcompr))]++;
} }
} }
}
return 1; return 1;
} }