Masking Brush

So I just challenge myself to do some photo editing and I was thinking some ideas that would be easier to manage to do this process inside Krita.


  • brush engine or pixel brush option to activate. This is not important for me how it is activated.
  • the color active inside Krita with this brush will target that color in the canvas.
  • the brush settings would indicate the variation to nearby colors around the targeted color.
  • when painting on canvas it would sample all available colors on the screen even considering active channels BGRA or just BR per example. this is Important.
  • when painting it will paint white in normal state and paint black when the eraser is active.
  • Opacity might be another factor to have in consideration to target
  • it paints on a simple pixel layer.
  • My example is with HSV but I believe it would work very well with HSY and LCH. HSV would just be easier to consider for a first case implementation.


  • Target Color - This is the RGB mid that will give the HSV mid.
  • (Hue, Saturation, Value) Amplitude - amount of range around the RGB mid that is considered.
  • Range - Area that consists of 2 tris and 1 quad. the quad is the section where 100% will be considred and the tris are linear interpolations to zero. The sizes of these would be adjustable in the settings.

By painting Black or White you can create masks more easily. This leaves the brush able to do other operations since colors is not coming out but a factor of consideration to paint the mask with. Using a brush that creates the mask is easier to go around fringe cases like you wanting to paint the positive on one side and right next to it painting the negative. this would mean creating 2 different filters at least and editing both their masks which is a bore and very time consuming to set up, might as well be using nodes by that point instead of layers then. you could just make one layer and use the eraser alternate what your leaving in or not.


This would increase speed in creating masks. Would make hair masking easier which is one of the most hardest masks to create. Would bring the elegance of hand painting with pressure to calibrate the amount of masking on any given spot without having to change the whole filter for one tiny section. Technically is not inventing nothing new in terms of things to take in account for just assemble them in another way this means easier to implement but not actually faster to implement.

I think I like my foreground selection idea better if by masking, you mean generation of selection. I already have code to work on though another person here has my code as well.

I have no clue what your referring too.

not directly. masks are selections but not marching ants selections.

I was curious to what you even meant and I started searching the forum and I found what you are referring to in your response.

After testing the G’MIC filter I can safely say this is not good enough mask complex situations like hair or glass reflections, as it would be expected from any automated process even with the control points marks. This filter at most gives you a good jump start on most simple cases for people that dont know nothing and you will still fall under the same problem after when your forced to tweak the mask after the fact.

What I imagine this is good to masking animations if the control points would be animatable that would prove worth. Colorize mask has the same exact issue as this as a good fill tool would easily surpass that filter for static images which is the main focus of Krita.

For masking what you really need is channel control and be able to swap between different color conditions (by swapping channels or applying filters even if for just a bit) to paint your mask on one section and another condition for another section(this is the main down fall of filters). If the automated step does not even consider this are not really a viable solution to replace other already in place methods they just need a extra touch.

what I propose is a really ease to pick up and to use BUT able to solve different fringe cases in the image because lighting conditions are never the same all throughout. That is why the color selected is the color target of the image to paint the mask so you can easily paint and clean up.

Even after you make your filter you will probably have to fix odd cases with something like what i am suggesting. Not to mention just changing a brush to do something is always quicker than finding a filter and setting it up several times for different sections of the image when you can just pick a nearby color and continue painting.

Not to mention something like this would make the channels docker something worthwhile to use.
Also the code to implement this already exists and does not need new algorithms.

You gotta remember your in a layers workflow so you do not have the luxury of nodes to adjust without loosing insane amounts of time IF you don’t mess up the process to bake the information out, nothing is reusable here. But you have the ability of being able to set a dynamic system to paint with because if your making masks in Krita that is probably the reason your here in the first place. Because for simple cases vector that is animatable is probably the best option in all cases it is painted pixels that needs attention, that is where others lack and where Krita excels.

Because trying to compete with Nuke or After for automated foreground removal is a battle already lost… what they don’t have proper is good pixel painterly adjustments that is what they don’t have.

Um, the code that I was referring is actually on C++, and utilize guided filtering. The problem within that code so far is the generation of selection after clicking outside of selection. It’s noisy, and I don’t know how to solve that problem. Other than that, it works as expected.