[gimp] Issue #3062 - Picking by hue using "Select by Color" goes awry ...
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Issue #3062 - Picking by hue using "Select by Color" goes awry ...
- Date: Tue, 5 Mar 2019 14:02:14 +0000 (UTC)
commit 9886b69dacfd200bcd34e7e25f01f8c7c7983b97
Author: Ell <ell_se yahoo com>
Date: Tue Mar 5 08:41:58 2019 -0500
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.
app/core/gimppickable-contiguous-region.cc | 54 +++++++++++++++++++++++++++---
1 file changed, 50 insertions(+), 4 deletions(-)
---
diff --git a/app/core/gimppickable-contiguous-region.cc b/app/core/gimppickable-contiguous-region.cc
index 817ba31e55..de44f25cc1 100644
--- a/app/core/gimppickable-contiguous-region.cc
+++ b/app/core/gimppickable-contiguous-region.cc
@@ -721,8 +721,31 @@ pixel_difference (const gfloat *col1,
break;
case GIMP_SELECT_CRITERION_H:
- max = fabs (col1[0] - col2[0]);
- max = MIN (max, 1.0 - max);
+ if (col1[1] > EPSILON)
+ {
+ 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;
case GIMP_SELECT_CRITERION_S:
@@ -742,8 +765,31 @@ pixel_difference (const gfloat *col1,
break;
case GIMP_SELECT_CRITERION_LCH_H:
- max = fabs (col1[2] - col2[2]) / 360.0;
- max = MIN (max, 1.0 - max);
+ if (col1[1] > 100.0 * EPSILON)
+ {
+ 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;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]