Picking by hue using "Select by Color" goes awry in GIMP 2.10.9 from git
I made a test file with 6 columns of color dots. In each column the color dots have roughly the same LCh hue and Lightness, varying only in Chroma. The background for each column is neutral gray at roughly the Lightness of the color dots in that column. There are some other neutral gray areas in the image.
I picked the bottom dot in each column, one column at a time, using "Select by Color" using the same tool settings as in the screenshot in this bug report: #3058 (closed) - the test file can be downloaded from the same bug report.
The expected behavior is that all and only the color dots in the given column are selected. This is what happens most of the time, but sometimes more or less large areas of the neutral gray background are also picked. Here's a video (to the right in the video is the same image in GIMP-CCE, which doesn't show this odd behavior):
simplescreenrecorder-2019-03-04_17.21.53
So in GIMP-2.10 neutral areas are being randomly picked when trying to pick colors by hue. This would make sense if any of the colors in the columns had a hue of 0/360, as by definition "neutral gray" is assigned the hue 0/360. In GIMP-CCE, AFAIK neutral gray always does have h=0/360 except when importing images created using GIMP-2.10. But in GIMP-2.10/2.99 the actual "hue" of neutral gray varies, randomly, but apparently somewhat correlated with:
- when I painted/bucket-filled the neutral gray area (the test image was created using GIMP-2.10.9).
- misbehaving LCh sliders per #2929 (closed).
- sudden changes in the "hue" of neutral gray areas from things like changing precision.
Also when trying to dial in neutral gray in 2.10 (and in 2.99) some hues are more often randomly assigned to "gray" than others. For example h=90 is a commonly encountered hue for "gray", as shown by large areas of the image in GIMP-2.10.9 being selected when I clicked on the bottom circle in the yellow column. Color-picking around the image, indeed there are various "hues" for neutral gray.
Here is a suggested workaround:
When someone is picking hues by Color or by Hue, they really do not expect to end up selecting neutral gray areas. So if the Chroma is zero - or rather less than some fixed amount that's very, very close to zero - then when picking by Color or by Hue, don't include these "very very close to zero Chroma" colors in the resulting selection.
It would be nice to also fix the random hues for neutral gray. Maybe there is a rounding error somewhere? Possibly tied to precision and bit depth changes? And/or to using floating point instead of double? Or from some other "make it faster" code?
As an aside, trying to fill the "incorrect hue for neutral gray areas" by dialing in the desired hue using the color tools, and then painting/bucket-filling, seems to be not very effective. But selecting and using the Hue-Chroma tool does allow to sometimes? always? at least temporarily reset the hue of gray to 0.