Issue #3062 - Picking by hue using "Select by Color" goes awry ...

... in GIMP 2.10.9 from git

In gimppickable-contiguous-region's pixel_difference() function,
which is used, among other things, by the select-by-color and
fuzzy-select tools, when selecting by LCh/HSV hue, treat a pair of
colors as inifinitely far apart if one of them has positive chroma/
saturation, and the other has chroma/saturation that's very close
to 0; conversely, treat a pair of colors as equal if both of them
have chroma/sautation that's close to 0.

As a result, when the seed color is saturated, gray pixels are
never selected, while when the seed color is desaturated, all, and
only, gray pixels are selected.
This commit is contained in:
Ell
2019-03-05 08:41:58 -05:00
parent 0a5b3ec82f
commit 9886b69dac

View File

@ -721,8 +721,31 @@ pixel_difference (const gfloat *col1,
break; break;
case GIMP_SELECT_CRITERION_H: case GIMP_SELECT_CRITERION_H:
max = fabs (col1[0] - col2[0]); if (col1[1] > EPSILON)
max = MIN (max, 1.0 - max); {
if (col2[1] > EPSILON)
{
max = fabs (col1[0] - col2[0]);
max = MIN (max, 1.0 - max);
}
else
{
/* "infinite" difference. anything >> 1 will do. */
max = 10.0;
}
}
else
{
if (col2[1] > EPSILON)
{
/* "infinite" difference. anything >> 1 will do. */
max = 10.0;
}
else
{
max = 0.0;
}
}
break; break;
case GIMP_SELECT_CRITERION_S: case GIMP_SELECT_CRITERION_S:
@ -742,8 +765,31 @@ pixel_difference (const gfloat *col1,
break; break;
case GIMP_SELECT_CRITERION_LCH_H: case GIMP_SELECT_CRITERION_LCH_H:
max = fabs (col1[2] - col2[2]) / 360.0; if (col1[1] > 100.0 * EPSILON)
max = MIN (max, 1.0 - max); {
if (col2[1] > 100.0 * EPSILON)
{
max = fabs (col1[2] - col2[2]) / 360.0;
max = MIN (max, 1.0 - max);
}
else
{
/* "infinite" difference. anything >> 1 will do. */
max = 10.0;
}
}
else
{
if (col2[1] > 100.0 * EPSILON)
{
/* "infinite" difference. anything >> 1 will do. */
max = 10.0;
}
else
{
max = 0.0;
}
}
break; break;
} }
} }