Bug 780065 - Change default way to desaturate to Luminance

which unlike HSL Lightness is actually physically meaningful and
also generally speaking much more useful than HSL Lightness.

Change "Lightness" to "Lightness (HSL)" to make it clear that
the "Lightness" in the Colors/Desaturate/Desaturate menu is not the
same as "Lightness" in LAB/LCH.

For completeness add the option to desaturate to "Value (HSV)".

Add links in app/operations/gimpoperationdesaturate.c
to the Wikipedia article with definitions of L/I/V in HSL/HSI/HSV.
This commit is contained in:
Elle Stone 2017-03-17 16:20:40 -04:00
parent 5ea5458938
commit 48e4044672
4 changed files with 41 additions and 9 deletions

View File

@ -90,7 +90,7 @@ gimp_operation_desaturate_class_init (GimpOperationDesaturateClass *klass)
_("Mode"),
_("Choose shade of gray based on"),
GIMP_TYPE_DESATURATE_MODE,
GIMP_DESATURATE_LIGHTNESS,
GIMP_DESATURATE_LUMINANCE,
GIMP_PARAM_STATIC_STRINGS);
}
@ -173,6 +173,9 @@ gimp_operation_desaturate_process (GeglOperation *operation,
switch (desaturate->mode)
{
case GIMP_DESATURATE_LIGHTNESS:
/* This is the formula for Lightness in the HSL "bi-hexcone"
* model: https://en.wikipedia.org/wiki/HSL_and_HSV
*/
while (samples--)
{
gfloat min, max, value;
@ -211,6 +214,9 @@ gimp_operation_desaturate_process (GeglOperation *operation,
break;
case GIMP_DESATURATE_AVERAGE:
/* This is the formula for Intensity in the HSI model:
* https://en.wikipedia.org/wiki/HSL_and_HSV
*/
while (samples--)
{
gfloat value = (src[0] + src[1] + src[2]) / 3;
@ -220,6 +226,27 @@ gimp_operation_desaturate_process (GeglOperation *operation,
dest[2] = value;
dest[3] = src[3];
src += 4;
dest += 4;
}
break;
case GIMP_DESATURATE_VALUE:
/* This is the formula for Value in the HSV model:
* https://en.wikipedia.org/wiki/HSL_and_HSV
*/
while (samples--)
{
gfloat value;
value = MAX (src[0], src[1]);
value = MAX (value, src[2]);
dest[0] = value;
dest[1] = value;
dest[2] = value;
dest[3] = src[3];
src += 4;
dest += 4;
}

View File

@ -505,15 +505,17 @@ gimp_desaturate_mode_get_type (void)
{ GIMP_DESATURATE_LUMA, "GIMP_DESATURATE_LUMA", "luma" },
{ GIMP_DESATURATE_AVERAGE, "GIMP_DESATURATE_AVERAGE", "average" },
{ GIMP_DESATURATE_LUMINANCE, "GIMP_DESATURATE_LUMINANCE", "luminance" },
{ GIMP_DESATURATE_VALUE, "GIMP_DESATURATE_VALUE", "value" },
{ 0, NULL, NULL }
};
static const GimpEnumDesc descs[] =
{
{ GIMP_DESATURATE_LIGHTNESS, NC_("desaturate-mode", "Lightness"), NULL },
{ GIMP_DESATURATE_LIGHTNESS, NC_("desaturate-mode", "Lightness (HSL)"), NULL },
{ GIMP_DESATURATE_LUMA, NC_("desaturate-mode", "Luma"), NULL },
{ GIMP_DESATURATE_AVERAGE, NC_("desaturate-mode", "Average"), NULL },
{ GIMP_DESATURATE_AVERAGE, NC_("desaturate-mode", "Average (HSI Intensity)"), NULL },
{ GIMP_DESATURATE_LUMINANCE, NC_("desaturate-mode", "Luminance"), NULL },
{ GIMP_DESATURATE_VALUE, NC_("desaturate-mode", "Value (HSV)"), NULL },
{ 0, NULL, NULL }
};

View File

@ -279,10 +279,11 @@ GType gimp_desaturate_mode_get_type (void) G_GNUC_CONST;
typedef enum
{
GIMP_DESATURATE_LIGHTNESS, /*< desc="Lightness" >*/
GIMP_DESATURATE_LUMA, /*< desc="Luma" >*/
GIMP_DESATURATE_AVERAGE, /*< desc="Average" >*/
GIMP_DESATURATE_LUMINANCE, /*< desc="Luminance" >*/
GIMP_DESATURATE_LIGHTNESS, /*< desc="Lightness (HSL)" >*/
GIMP_DESATURATE_LUMA, /*< desc="Luma" >*/
GIMP_DESATURATE_AVERAGE, /*< desc="Average (HSI Intensity)" >*/
GIMP_DESATURATE_LUMINANCE, /*< desc="Luminance" >*/
GIMP_DESATURATE_VALUE, /*< desc="Value (HSV)" >*/
#ifndef GIMP_DISABLE_DEPRECATED
GIMP_DESATURATE_LUMINOSITY = GIMP_DESATURATE_LUMA /*< skip, pdb-skip >*/

View File

@ -157,11 +157,13 @@ package Gimp::CodeGen::enums;
{ contig => 1,
header => 'libgimpbase/gimpbaseenums.h',
symbols => [ qw(GIMP_DESATURATE_LIGHTNESS GIMP_DESATURATE_LUMA
GIMP_DESATURATE_AVERAGE GIMP_DESATURATE_LUMINANCE) ],
GIMP_DESATURATE_AVERAGE GIMP_DESATURATE_LUMINANCE
GIMP_DESATURATE_VALUE) ],
mapping => { GIMP_DESATURATE_LIGHTNESS => '0',
GIMP_DESATURATE_LUMA => '1',
GIMP_DESATURATE_AVERAGE => '2',
GIMP_DESATURATE_LUMINANCE => '3' }
GIMP_DESATURATE_LUMINANCE => '3',
GIMP_DESATURATE_VALUE => '4' }
},
GimpDodgeBurnType =>
{ contig => 1,