gimp r26984 - in trunk: . app/gegl
- From: simon svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r26984 - in trunk: . app/gegl
- Date: Wed, 17 Sep 2008 22:55:56 +0000 (UTC)
Author: simon
Date: Wed Sep 17 22:55:55 2008
New Revision: 26984
URL: http://svn.gnome.org/viewvc/gimp?rev=26984&view=rev
Log:
2008-09-18 Simon Budig <simon gimp org>
* app/gegl/gimpbrightnesscontrastconfig.c: fix the
brightness/contrast --> levels step by doing proper math (TM).
Modified:
trunk/ChangeLog
trunk/app/gegl/gimpbrightnesscontrastconfig.c
Modified: trunk/app/gegl/gimpbrightnesscontrastconfig.c
==============================================================================
--- trunk/app/gegl/gimpbrightnesscontrastconfig.c (original)
+++ trunk/app/gegl/gimpbrightnesscontrastconfig.c Wed Sep 17 22:55:55 2008
@@ -162,7 +162,7 @@
{
GimpLevelsConfig *levels;
gdouble brightness;
- gdouble contrast;
+ gdouble slant;
gdouble value;
g_return_val_if_fail (GIMP_IS_BRIGHTNESS_CONTRAST_CONFIG (config), NULL);
@@ -170,33 +170,63 @@
levels = g_object_new (GIMP_TYPE_LEVELS_CONFIG, NULL);
brightness = config->brightness / 2.0;
- contrast = (config->contrast < 0 ?
- (config->contrast + 1.0) :
- config->contrast * 4.0 + 1.0);
+ slant = tan ((config->contrast + 1) * G_PI_4);
- value = -0.5 * contrast + brightness + 0.5;
-
- if (value < 0.0)
+ if (config->brightness >= 0)
{
- value = 0.0;
+ value = -0.5 * slant + brightness * slant + 0.5;
- levels->low_input[GIMP_HISTOGRAM_VALUE] =
- (-0.5 - brightness) / contrast + 0.5;
- }
+ if (value < 0.0)
+ {
+ value = 0.0;
- levels->low_output[GIMP_HISTOGRAM_VALUE] = value;
+ /* this slightly convoluted math follows by inverting the
+ * calculation of the brightness/contrast LUT in base/lut-funcs.h */
- value = 0.5 * contrast + brightness + 0.5;
+ levels->low_input[GIMP_HISTOGRAM_VALUE] =
+ (brightness * slant + 0.5 * slant - 0.5) / (slant - brightness * slant);
+ }
- if (value > 1.0)
- {
- value = 1.0;
+ levels->low_output[GIMP_HISTOGRAM_VALUE] = value;
+
+ value = 0.5 * slant + 0.5;
- levels->high_input[GIMP_HISTOGRAM_VALUE] =
- (0.5 - brightness) / contrast + 0.5;
+ if (value > 1.0)
+ {
+ value = 1.0;
+
+ levels->high_input[GIMP_HISTOGRAM_VALUE] =
+ (brightness * slant + 0.5 * slant + 0.5) / (slant - brightness * slant);
+ }
+
+ levels->high_output[GIMP_HISTOGRAM_VALUE] = value;
}
+ else
+ {
+ value = 0.5 - 0.5 * slant;
- levels->high_output[GIMP_HISTOGRAM_VALUE] = value;
+ if (value < 0.0)
+ {
+ value = 0.0;
+
+ levels->low_input[GIMP_HISTOGRAM_VALUE] =
+ (0.5 * slant - 0.5) / (slant + brightness * slant);
+ }
+
+ levels->low_output[GIMP_HISTOGRAM_VALUE] = value;
+
+ value = slant * brightness + slant * 0.5 + 0.5;
+
+ if (value > 1.0)
+ {
+ value = 1.0;
+
+ levels->high_input[GIMP_HISTOGRAM_VALUE] =
+ (0.5 * slant + 0.5) / (slant + brightness * slant);
+ }
+
+ levels->high_output[GIMP_HISTOGRAM_VALUE] = value;
+ }
return levels;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]