Author: akv
Date: 2012-10-28 17:12:15 +0100 (Sun, 28 Oct 2012)
New Revision: 4294
Modified:
trunk/librawstudio/rs-curve.c
Log:
Fixing 'auto adjust curve ends'.
Modified: trunk/librawstudio/rs-curve.c
===================================================================
--- trunk/librawstudio/rs-curve.c 2012-10-28 16:11:11 UTC (rev 4293)
+++ trunk/librawstudio/rs-curve.c 2012-10-28 16:12:15 UTC (rev 4294)
@@ -1082,29 +1082,37 @@
RSCurveWidget *curve = RS_CURVE_WIDGET(widget);
gint i = 0;
- gdouble black_threshold = 0.003; // Percent underexposed pixels
- gdouble white_threshold = 0.01; // Percent overexposed pixels
+ gdouble black_threshold = 0.2; // Percent underexposed pixels
+ gdouble white_threshold = 0.05; // Percent overexposed pixels
gdouble blackpoint;
gdouble whitepoint;
guint total = 0;
+ guint total_pixels = 0;
guint *hist;
hist = curve->histogram_data;
+ while(i < 256) {
+ total_pixels += hist[i];
+ i++;
+ }
+
// calculate black point
+ i = 0;
while(i < 256) {
- total += hist[i]+hist[i]+hist[i];
- if ((total) > ((250*250)/100*black_threshold))
+ total += hist[i];
+ if ((total) > ((total_pixels)/100*black_threshold))
break;
i++;
}
blackpoint = (gdouble) i / (gdouble) 255;
// calculate white point
+ total = 0;
i = 255;
while(i) {
- total += hist[i]+hist[i]+hist[i];
- if ((total) > ((250*250)/100*white_threshold))
+ total += hist[i];
+ if ((total) > ((total_pixels)/100*white_threshold))
break;
i--;
}
_______________________________________________
Rawstudio-commit mailing list
[email protected]
http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-commit