Floodfill features - updates

feature_proposal
Tags: #<Tag:0x00007fd8680cefc0>
#1

After far too long I will inform anyone who is interested about the state of the new* futuristic flood fill functionality™.

To recap, the old new features were:

dilation/erosion - being able to grow or shrink the fill by setting an offset
feathering - being able to blur the fill
gap closing - being able to not seep through gaps smaller than an adjustable size (while still filling into corners)

Since then, I’ve also added the ability to use the erase and lock alpha modes when using the fill tool, which can be useful when it is easier to block-brush a region and remove contiguous sections on the outside of it. Both of these could previously be accomplished by working on a separate layer and then using blending modes and layer groups to mask, but this is definitely more ergonomic.

I have also finally got around to building and testing on a Windows VM and apart from needing to figure out (or more likely, just conditionally disable) multiprocessing for morph operations, it all seems to work fine after a couple of easily squashed bugs were dealt with.

There are a couple more things I want to do in this area (selectable constant source layer, better option adjustment), but for now I think the change set is large enough as it is.

* Guaranteed no more than 50 years old

1 Like

#2

You should look into @dothiko work into the floodfil as well. He had some interesting ways to expand upon it as well.

0 Likes

#3

Yes! Reading and testing his branches was one of the first things I did. The only problem with his approach to morphological operations (dilation/erosion) is quadratic complexity. To be fair, that does not really matter for small offsets (which in practice will cover most use cases), but leads to severe slowdowns for larger ones.

His grabcut fill prototype is very interesting, but since it is essentially a separate mode I think a finished version of that could be added at a future point independent of any changes to the current tool set.

0 Likes

#4

Here are the new strings that would be added with this patch set (each bullet point is a separate string):

  • Offset:
  • The distance in pixels to grow or shrink the fill
  • Feather:
  • The amount of blur to apply to the fill
  • Use gap detection
  • Try to detect gaps and not fill past them.
    Note: this can be a lot slower than the regular fill,
    only enable when you really need it.
  • Max gap size:
  • The size of the largest gaps that can be detected
  • Prevent seeping
  • Try to prevent the fill from seeping into the gaps

(that’s it)

If anyone has any feedback or suggested changes about this I would be grateful. It’s easy to think that something is descriptive when you have been working on it for a while, when it’s really not. E.g. I changed “Retract seeps” to “Prevent seeping” to reflect what the option is supposed to achieve, rather than how it achieves it.

I also have a question about new strings, if anyone knows.
Should updated translation files be part of the pull request? Is it ok to generate them as a part of a separate commit or should I rebase to include them at the commits where the strings were originally added?

Also, apologies for some github issues being littered with references to commits which are no longer part of any active branch, I mistakenly thought that force pushing and branch deletion would clean those up.

0 Likes

#5

I’ll just answer this myself, based on a cursory look at the logs. It seems that the po-files are updated in one go as part of a string-freeze commit. Maybe this approach is common enough to not warrant documenting (or maybe I just didn’t find said documentation).

On the fill side, I went ahead and added static source selection, meaning that you can select any layer or layer group to act as the fill reference, regardless of which layer you are working on (filling into). The default is and “sample merged” overrides it.
Static fill references are very nifty when you need multiple fill layers and want to be able to work with each layer independently (without hiding/unhiding all the time, as might be necessary when using “sample merged”).

It’s basically like working with “sample merged” enabled but with a lot more flexibility (no need to disable backgrounds for example). You can even get the ordinary “sample merged” behaviour without the background layer included, by creating a single layer group containing the rest of the layer tree (including the fill layers) and setting that topmost group as the fill reference.

As an aside, I added keyboard toggling for gap detection, fill reference layer (between and <previous choice, if any>, and sample merged. The three are toggled by double tapping (within 0.5s) the left Shift, Control and Alt keys respectively. For obvious reasons, this will not make it into an actual release, but is useful for testing things out.

0 Likes