[gimp/gimp-2-10] Issue #3062 - Picking by hue using "Select by Color" goes awry ...



commit 4eda127c525bb68104ef04bddff2f798945a54d0
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.
    
    (cherry picked from commit 9886b69dacfd200bcd34e7e25f01f8c7c7983b97)

 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 df9d54a336..5469c22cc1 100644
--- a/app/core/gimppickable-contiguous-region.cc
+++ b/app/core/gimppickable-contiguous-region.cc
@@ -720,8 +720,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:
@@ -741,8 +764,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]