This is ripe ground for some fun algorithm design. The current lasso tool uses a basic edge detection algorithm which is fairly easy to understand, but the results are poor.
The tool needs a new icon, a new GUI, and many other additions.
dkazakov | |
rempt |
This is ripe ground for some fun algorithm design. The current lasso tool uses a basic edge detection algorithm which is fairly easy to understand, but the results are poor.
The tool needs a new icon, a new GUI, and many other additions.
No Linters Available |
No Unit Test Coverage |
Cool! Did you take a look at the old, 1.6 era algorithm? I'm not sure how good that was, though! I'm sure there are way better algorithms now :-) (Ah, I see it is :-))
Hi Boudewijn: I didn't look at any previous algorithm. My starting point was reverting a patch from early 2014 or so, but didn't dig deeper.
This is against Calligra 2.9 and it should be good to go out of the box! The algorithm itself still needs a lot of work on many dimensions, but you can lasso things reasonably with a little patience.
Hi, Michael!
I added a comment about icons. The rest looks fine to commit. But I guess we should wait until 2.9.7 release is branched on 29th of August
krita/plugins/tools/selectiontools/kis_tool_select_magnetic.h | ||
---|---|---|
166 | Here instead of koIconNameCStr("tool_magnetic_selection"), please use KisIconUtils::loadIcon("<icon_name>"). See [0] for more info. If will also allow you to avoid duplicating icons in the selectiontools/ directly and int pics/tools/16. I guess only one copy of the icons should be kept :) [0] - https://community.kde.org/Krita/docs/Icons_API_Roadmap |
Thanks for looking it over! I'll make the change. Do you think the alterations you linked to should be done in a script?
Right now I think the tool needs a lot more work before it's ready to expose to users so I might be holding off for more than another 8 days. One of the things on the to-do list I could use some advice.
The tool uses an edge-detection filter to determine where the lasso should be attracted by calling a function in real time. Since we look at the same points over and over again, it seems more efficient if we pre-cache the edge when the tool is activated, save it in a new buffer, then access the new buffer when we're using the tool. (Factoring out a black box giving the tool edge data also makes for a cleaner interface if we want to swap in a more advanced algorithm.) What classes would I want to look into for doing that? Or can you point me to an example of something similar elsewhere in the codebase?
Hi, Michael!
We have an KisOutlineGenerator class that performs all the outline generation for brushes and selections. You can see an example of usage in KisPixelSelection::outline().
If you like to do the calculation of the outline in a stroke you can use the stroke strategy. An example is in KisToolTransform::startStroke()->TransformStrokeStrategy::previewDevice(). I'm not sure if you really need this.
And I don't know if the icons change can be performed with a script :) If someone writes it, then, probably, yes. Right now it is a policy for a new code.
Maybe it would be handy to push this to master so it gets updated whenever something else needs updating?
I think I mentioned this a few times on IRC but forgot to write it down here: I am holding off on this until the Lazy Brush is finished, since the methods used in that tool will be very useful for implementing a new magnetic lasso.