Krita: Luminosity masks using Select from Color Range and Local Selection.

This topic will show how to set up luminosity masks in an easy and resource friendly way using Krita.

If you are used to another piece of software you need to figure out if certain ways of working and techniques (in general or software specific) can be done using the alternative software. Not being able to use a specific technique might be reason not to use this piece of software (at all or for specific cases).

I’m already past the ‘Is Krita good enough for images?’ stage and am now in the process of switching from GIMP to Krita to do final stage retouching and editing.

One of the things I tend to use regularly are multiple selections that I can target individually. There’s an example of that I posted here on pixls, done in GIMP: Faux balconies in B&W. If I remember correctly I used about 20 selections for this one.

While looking into selections, specifically how to save them (GIMP’s Save to Channel equivalent) I came across Krita’s Local Selection option. This makes it possible to add one or more selections to a specific layer(s) and/or group(s).

I also came across the Select from Color Range... option in the Select tab. This one doesn’t just use colours though, you can also use Highlights, Midtones or Shadows as your target. The real power lies in the fact that you can set/create specific ranges and add or subtract them from what’s already selected (if anything).

It wasn’t until later that I realized that these two combined could be used to create luminosity masks. And although I don’t use it often I have in the past and knowing that this is possible in Krita would be rather welcome.

OK, enough of the intro, lets get to the actual how-to and create 1 layer (the image), 7 selections (the luminosity masks) and a few Filter Masks.


This was done using Krita 4.4.3, but the initial searches and experiments started when I used version 4.4.2. I’m not sure if all the below functionality was available before these versions (I do think all is covered in at least version 4.0.0 and onward though).

Krita’s layout shown in the below examples aren’t the default, they are mine, but this should not in any way hinder the instructions given.


  1. Load an image (example images can be found at the bottom of this topic).

First we grab the darkest parts, this will become the DDD mask:

  1. Open the Select from Color Range... window: Select → Select from Color Range...

step.02a

step.02b

  1. Set target to Shadows (default is Reds), set Fuziness to 33 (right click to set it manually) and click on Select. A small sections should now show the marching ants.

step.03

Click on OK to finalize this action.

  1. Make sure that the image layer (called background in the example file) is selected and right click on it. From the menus select Add and then Local Selection. Alternatively you can user the little arrow next to the icon with the square and plus inside it ( ) and select Local Selection.

step.04

  1. Select the entry called Selection 1, press F2 and rename it to DDD


Grabbing the some what lesser darker parts, the DD mask:

  1. The current Local Selection is turned on and it needs to be turned off before we can continue: Click on the white star ( ). It should be greyed out now and the selection mask (red part) is now gone.

  1. Make sure that the image layer (‘background’) is selected,
  2. Open the Select from Color Range... window
  3. Set target to Shadows, set Fuzziness to 66 and click on Select.

step.09

We need to exclude (subtract) the part from the selection that was already covered in the previous step:

  1. Set Fuzziness to 33, tick Invert and tick Subtract from current selection and then click on Select.

step.10

Click on OK to finalize.

  1. Select the image layer, right click on it and from the menus select Add and then Local Selection
  2. Select the entry called Selection 2, press F2 and rename it to DD

Grabbing the lightest darker parts, the D mask:

  1. Turn Local Selection off: Click on the white star.
  2. Make sure that the image layer is selected
  3. Open the Select from Color Range... window
  4. Set target to Shadows, set Fuzziness to 100 and click on Select.
  5. Set Fuzziness to 66, tick Invert, tick Subtract from current selection, click on Select and the on OK.
  6. Select the image layer, right click on it and from the menus select Add and then Local Selection
  7. Select the entry called Selection 3, press F2 and rename it to D

All the Shadow related Local Selections (masks) have now been created. You can check to see if all went well by turning the individual Local Selections on/off. As shown here:


I make just one selection for the mid-tones (the M layer). The default setting (fuzziness 100) is rather large and overlaps both with the Shadows and the highlights. Using 29 will select the section that is left open after setting up both the shadows and highlights selections.

See the Q&A section for some extra information concerning the creation of multiple mid-tone sections.


The mid-tones, the M mask:

  1. Turn Local Selection off if one is turned on.
  2. Make sure that the image layer is selected
  3. Open the Select from Color Range... window
  4. Set target to Midtones, set Fuzziness to 29 and click on Select and then on OK
  5. Make sure that the image layer is selected, right click on it, select Add and then Local Selection
  6. Select the entry called Selection 4, press F2 and rename it to M

Creating the highlight selections. First the brightest parts, the LLL mask:

  1. Turn Local Selection off if one is turned on.
  2. Make sure that the image layer is selected
  3. Open the Select from Color Range... window
  4. Set target to Highlights, set Fuzziness to 33 and click on Select and then on OK
  5. Make sure that the image layer is selected, right click on it, select Add and then Local Selection
  6. Select the entry called Selection 5, press F2 and rename it to LLL

And a little less bright, the LL mask:

  1. Turn Local Selection off if one is turned on.
  2. Make sure that the image layer is selected
  3. Open the Select from Color Range... window
  4. Set target to Highlights, set Fuzziness to 66 and click on Select and then on OK
  5. Set Fuzziness to 33, tick Invert, select Subtract from current selection, click on Select and then OK
  6. Make sure that the image layer is selected, right click on it, select Add and then Local Selection
  7. Select the entry called Selection 6, press F2 and rename it to LL
  8. With the LL mask selected press on the Move layer or mask down icon

The last and least bright of the highlight selections (the L mask):

  1. Turn Local Selection off if one is turned on.
  2. Make sure that the image layer is selected
  3. Open the Select from Color Range... window
  4. Set target to Highlights, set Fuzziness to 100 and click on Select and then on OK
  5. Set Fuzziness to 66, tick Invert, select Subtract from current selection, click on Select and then OK
  6. Make sure that the image layer is selected, right click on it, select Add and then Local Selection
  7. Select the entry called Selection 7, press F2 and rename it to L
  8. With the LL mask selected press on the Move layer or mask down icon twice.

All seven layers have now been created and are ready to be used.


Having a masking framework is nice and all but how do you make use of all this?

  1. There’s only one layer in this example, but make sure it is selected.
  2. Turn on the M mask using the star icon (do not select it though).

a1

  1. Select a Filter Mask: Filter, Adjust then Levels. Adjust the levels to your liking and click on Create Filter Mask
    A new entry has been added and automatically selected in the layers docker called Levels
    Press F2 and rename it to M Levels. I would also move it to just below the M mask.

a2

NOTE: There is a big difference between using Create Filter Mask or pressing OK when you are done with adjusting the Filter Mask. Pressing OK results in a one time, destructive action, Create Filter Mask on the other hand makes an entry that is accessible at any time and thus can be used to make changes later on if needed.

Lets add another Filter Mask, this one to the LL mask.

  1. Select the image layer
  2. Turn on the LL mask
  3. Select a Filter Mask: Filter, Adjust then HSV Adjustments. Select Colorize and turn up the Saturation slider. Click on Create Filter Mask when done.
  4. Rename it and move it to below the LL mask.

a3

You are not limited to 1 Filter Mask per Local Selection, you can add as many as you like/need.

  1. Select the image layer
  2. Turn on the M mask
  3. Select a Filter Mask: Filter, Adjust then HSV Adjustments. Select Colorize and turn up the Saturation slider. Click on Create Filter Mask when done.
  4. Rename, and move below the M mask.

a4

At any point in time you can change the settings for the Filter Masks as follows:

  1. Select the Filter Mask that needs to be changed (M Levels in this case) and press F3 (or right click on the Filter Mask and select Properties). You’re presented with a window that allows you to change the settings made.

Here’s a short video showing the last 12 steps, with also an alternative way to select a Filter Mask. As you can see you don’t need to turn off a Local Selection if you want to adjust a Filter Mask that is not associated with it:

One last thing; You can still make global adjustments on the image even though there are multiple Local Selections present. If you do not turn on a Local Selection (everything is off) and select the image layer you can add/apply any Filter Mask, globally to the image and all the other local changes will also be applied.


Q&A section

  • Does it take long to set all this up?

Nope. The above framework looks like a lot of work, but it can be done in a few minutes.

  • Are the numbers/ranges used special in any way?

No, they are not. But…

I used these as a starting point because they are convenient. Fuzziness 100 is the default setting when using Select from Color Range... and I evenly divided that three ways to get to 33 and 66.

You do need to make sure that the total luminosity range is covered if you change the numbers! If both the highlights and shadows section use the same range (0-100 in this case) it is relatively easy to figure out what the range needs to be for the mid-tones (0-29 in this case).

If you want to experiment yourself I would suggest you first set the mid-tone range and than make the highlights/shadows section fit that range. I also would strongly advise to create an image like the one I used in this how-to if you want to create a better/different/personalized version.

Setting up a different spread using a real life image is impossible. Once you have figured out the numbers you can blindly apply them to real images.

Here’s another way of dividing the shadows, mid-tones and highlights:

Highlights: 0-80
Midtones 0-55
Shadows 0-75

This setup gives you more room in the mid-tones and both the shadows and highlights are thus pushed outward a bit. Dividing them in 2,3 or 4 sections each should be easy with the above steps.

  • Why am I not able to create multiple mid-tone sections using add, subtract and invert as described above?

Adding and subtracting using the mid-tones sections does not work the same as for the shadows or highlights. The shadows work from left to right, the highlights from right to left and the mid-tones start in the middle. This means that selections are determined from the middle outwards (to both sides at the same time).

Some creativity is needed to make multiple mid-tone sections:

Assuming the example given in the previous question and there being a mid-tones gap of 55 which you want to divide this into 2 sections:

creating the ML mask

  • first create the full mid-tone section using 55 (see steps 20-25). This will select the complete mid-tone range,
  • switch from Midtones to Shadow, tick invert, tick Subtract from current selection, set Fuzziness to 125 and click on Select and OK This created the mask for the mid-tones on the highlight side.

creating the MD mask

  • again create the full mid-tone section using 55. This will select the complete mid-tone range,
  • switch from Midtones to Highlights, tick invert, tick Subtract from current selection, set Fuzziness to 135 and click on Select and OK This created the mask for the mid-tones on the shadows side.

You might need to fiddle with the numbers (125 and 135) a bit to get it to your liking, but the above describes the way to approach the issue of creating multiple mid-tone selections.

There’s an alternative: Only use the shadows and highlight sections and use values larger than 100. Name the ones above 100 MD, M and ML (or MMM, MM, M or whatever you prefer). In the end it is about the masks that need to be created, not necessarily which tool section that is being used.

  • Can the Local Selections be changed once they are created?

Yes, I said cautiously…

As long as there are no Filter Masks that use that specific Local Selection they can be changed without any problems. So adding, subtracting,growing,shrinking and/or feathering can be done afterwards if wanted/needed.

Things become a bit more complicated once a Filter Mask is applied using a Local Selection. The Filter Mask is set up using the mask from the Local Selection in question and it will not have any knowledge about the changed Local Selection once it is set up. It isn’t attached to it, but rather uses the info from the Local Selection.

So if, for example, you decide the mid-tones do need to have 2 sections (MD and ML instead of M) you need to delete the associated filter mask(s) first.

  • Are there downsides to this method of doing it?

Maybe, it depends…

Yes if you are not very organized when setting this up. Appropriately naming your Local Selections and, more importantly, the Filter Masks that go with those selections is a must. I personally move the Filter Masks below the Selection they belong to for extra clarity (as shown in the above steps).

I have not found an easy, at first glance way to determine which Filter Mask is linked to which Local Selection. You can hover over the Filter Mask or Local Selection and Krita will show some basic information in a pup-up window. Among that is the mask itself.

  • Are there alternative ways of doing this?

Yes. @Reptorian created a tutorial early last year: Pat David Luminosity Mask for Krita 4.3 Tutorial.

It is a bit convoluted. Here’s a quote from that tutorial:

[…] so I made a tutorial. It’s far more convoluted than on GIMP or Photoshop, but most certainly possible. I tried to make it as simple as possible even though it’s hard to follow along.

I do recommend having a good look at it though, it uses some nice Krita features, Clone Layers to name one, and shows that intricate/complicated things can be done with Krita.

  • Can this be scripted?

Yes. For those that are Python savvy and don’t mind going through some on-line documentation: Just about everything can be scripted in Krita.

As of version 4.4.0 Python Scripting is available. This includes a simple programming interface (Tools → Scripts → Scripter). Links to the Krita APIs are to be found in the above mentioned link.



License: CC BY-NC-SA 4.0

3 Likes

I read this one a few times and did not come across any blatant errors. If you do, please let me know so I can fix them.

1 Like

Here’s a video version of setting up the above described 7 luminosity masks for the TL;DR crowd :slight_smile:

The image I used: P1001666.tif (17.6 MB)
And the Krita project file: P1001666.kra (30.4 MB)

License: CC BY-NC-SA 4.0

Very nice write up! Thank you for sharing.

Thanks for all the work putting this together. I have had the odd play with Krita and like it a lot. I know it’s intended as a painting program but sometimes I wish it just had a few more photo filters and was able to do a few things extra such as aligning layers, then it would be a killer application that covered most needs…

Thanks!

I really like working with Krita even though I’m still figuring out stuff. I noticed that I’ve started to use it more and more and actually want to start it up to use it. At the moment I only use GIMP for stuff that I haven’t yet figured out how to do in Krita or what cannot be done in Krita. There’s not all that much though, not for my workflow.

First and foremost you have got to love Krita’s non-destructive way of working. This alone is worth the switch!

It is also very actively developed, has a great user base, good documentation and a dedicated forum (2 actually). Oh, and a lot of videos, albeit 95% of them are painting/drawing related.

One thing that I came across that GIMP does a lot better: Smart erasure/replacement of large/complicated objects. Krita can do cloning and has a very decent smart patch tool and both work wonders when doing retouching, but that is about it (seen from a photographers point-of-view).

There are other things that you might consider to be missing: No channel mixer or setting sample points. But I’m not sure if that is fair though; Krita has, for example, more colour related tools and a killer colour related plugin called Pigment.O. So both “issues” can be tackled, but not in the way one is used to when coming from GIMP.

At its core it is a platform to create digital art. Or to quote from the docs:

Explicitly supported fields of painting are illustrations, concept art, matte painting, textures, comics and animations.

In the end it does depend on what you want to use it for and how willing you are to switch to an alternative (habits and already knowing how certain tools work are strong captors).

I did some experiments over the last few weeks to find out if Krita could replace GIMP, which I’m reasonably proficient in but don’t really like using.

One of those experiments/tests was an elaborate retouching session. Actually this where 3 different experiments, but all used the same subject and roughly the same format. These dealt with using/changing/creating brushes for specific needs, frequency separation and wavelet decompose, changing/replacing the background, restoring missing parts, sophisticated dodge/burn and using assist layers (or check layers or whatever you want to call them). All of them in a non-destructive way if at all possible (spoiler: you can).

I’ll have a look if I can merge the best parts of these experiment projects into a new project, a nice test in and of itself. I would also need to do some cleaning up and finishing touches to make it representable 'cause my experiments almost never reach a ready for publication stage, there’s no need once I figured out how/if something works.

I’m sure I’ll do this now that I came to think of it. Krita needs a bit more love here at pixls, so some more Krita related posts can only be a good thing :smile:

BTW:

Yeah, vector related stuff can be aligned, but normal layers are a bit harder to do. You can though and be pixel precise, but it is a manual task. That is assuming snapping to (self created) grids, guides and a handful of pre-defined snapping points isn’t good enough to do the job.

That’s something I have been working on addressing though I’m exhausted now and then with several of my projects, and one which I don’t want to show here.

1 Like

Oh, that would be a nice-to-have! Only thing that I actually miss.

No pressure though, I’m aware how the FOSS world works.

There is already a bug report for this. This will also help painters and book cover artists, the bug report is confirmed, if any volunteer or dev gets interested it might be added to krita.

2 Likes

Thanks. That’s good to know, it would be great if somebody had time to sort it out, as it will make many tasks a lot easier.