Bug 385160 - [Fill Tool] minimal Threshold is not fine enough
Summary: [Fill Tool] minimal Threshold is not fine enough
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: Tools (show other bugs)
Version: 3.3.0
Platform: Appimage Linux
: NOR normal
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-09-28 03:35 UTC by David REVOY
Modified: 2018-03-12 12:28 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
[^ PNG test file ; block of colors you can't fill at threshold 1 ] (2.99 KB, image/png)
2018-03-11 13:20 UTC, David REVOY
Details

Note You need to log in before you can comment on or make changes to this bug.
Description David REVOY 2017-09-28 03:35:35 UTC
Hi,
The fill tool can't replace exactly a single color: even at minimal Threshold, it still bleeds on neighborhood colors if those one are very close in the color-space.

To reproduce:
=============
1. Create a new sRGB document 60x20px
2. Create three filled square with three very near color, like this three red-black:
+------------+------------+------------+
| RGB(1,0,0) | RGB(2,0,0) | RGB(3,0,0) |
+------------+------------+------------+
3. Use the fill tool at minimal Threshold to replace a single color by a new random one ...

Result:
=======
All the three colors blocks will be filled by flood fill.

Expected:
=========
At minimal Threshold, I was expecting Flood fill tool to be super fine and precise to limit itself at a pure color, and fills only one block.

( Note: Bug found by Aninimouse, reported on forum here: https://forum.kde.org/viewtopic.php?f=139&t=141927 )
Comment 1 Halla Rempt 2018-01-18 10:05:50 UTC
This is because our color comparison function uses the deltaE function from lcms on the colors converted to Lab. It's the official way to compare colors, but if the threshold is one, we should do a simple equality.
Comment 2 Halla Rempt 2018-01-18 14:08:05 UTC
Git commit ba03f03732a1b9a957c0ad0cb8cfbd78e64347d5 by Boudewijn Rempt.
Committed on 18/01/2018 at 14:07.
Pushed by rempt into branch 'master'.

Do an exact match of the color if threshold is set to 1

If the threshold is set to 1, checking the difference between
colors through a conversion to lab and cmsDeltaE will not be
precise enough. A threshold of 1 means that no difference at
all is allowed.

This patch checks in relevant places whether the threshold is
1 and then does a memcmp.

M  +21   -7    libs/image/floodfill/kis_scanline_fill.cpp
M  +1    -1    libs/pigment/KoColorSpace.h
M  +2    -2    libs/ui/widgets/KisVisualColorSelectorShape.cpp
M  +5    -5    plugins/filters/imageenhancement/kis_simple_noise_reducer.cpp
M  +11   -1    plugins/filters/unsharp/kis_unsharp_filter.cpp
M  +11   -4    plugins/tools/selectiontools/kis_tool_select_similar.cc

https://commits.kde.org/krita/ba03f03732a1b9a957c0ad0cb8cfbd78e64347d5
Comment 3 David REVOY 2018-03-11 13:20:58 UTC
Created attachment 111321 [details]
[^ PNG test file ; block of colors you can't fill at threshold 1 ]

Hi, 

I reopen this report because of a problem in the bug-fix causing a regression. Now the fill tool is less accurate at threshold 1 (I tested on a previous revision). Now at threshold 1, the fill tool can't do difference between all color with the same Blue channel value. I attach a PNG image with very different block of colors and Krita will blindly fill them all together at threshold 1 because all this block have in commons the same Blue value ( 84 in this example ). 

To reproduce:
=============
1. Open the PNG in attachement
2. Select the fill tool (F)
3. In tool-option docker, set the threshold to "1"
4. Select a color of your choice, try to fill a single block.

Result:
=======
Every block will be colored.

Here is also a gif animation during coloring an artwork: https://www.peppercarrot.com/extras/temp/2018-03-11_fill-bug-value-1.gif
Comment 4 Halla Rempt 2018-03-12 12:28:18 UTC
Git commit 4e9d403738a99f23fe50268621348171d34008da by Boudewijn Rempt.
Committed on 12/03/2018 at 12:27.
Pushed by rempt into branch 'master'.

Fix comparing colors if fuzziness is 1

M  +14   -3    libs/image/floodfill/kis_scanline_fill.cpp
M  +1    -1    plugins/tools/selectiontools/kis_tool_select_similar.cc

https://commits.kde.org/krita/4e9d403738a99f23fe50268621348171d34008da
Comment 5 Halla Rempt 2018-03-12 12:28:28 UTC
Git commit 0ef6188824f401acce4843ebf16643711027cc38 by Boudewijn Rempt.
Committed on 12/03/2018 at 12:28.
Pushed by rempt into branch 'krita/4.0'.

Fix comparing colors if fuzziness is 1
(cherry picked from commit 4e9d403738a99f23fe50268621348171d34008da)

M  +14   -3    libs/image/floodfill/kis_scanline_fill.cpp
M  +1    -1    plugins/tools/selectiontools/kis_tool_select_similar.cc

https://commits.kde.org/krita/0ef6188824f401acce4843ebf16643711027cc38