How to Change the Color of Part of an Image in Krita

Share
In this tutorial, we'll learn how to add change the color of part of an image or photo in Krita (version 5.2). We can use this technique to change the color of a person's eyes in a photo, of a person's hair, of a person's clothes, the color of objects like cars and houses, and even to do things like whitening teeth by removing the color of the teeth.

To change the color of part of an image in Krita, follow the following steps:

1: open the image you want to edit in Krita.

2: select the part of the image that you want to modify.

Krita's selection tools: rectangular, elliptical, polygonal, lasso, magic wand, similar color, Bézier curve, and magnetic curve.
Krita's selection tools, as seen in its toolbox.

3: add a new non-destructive filter with a filter layer by clicking on the down arrow button next to the add layer button in the "Layers" docker. When we add a new filter layer with a selected area active, the selected area automatically becomes part of the internal mask of the filter layer.

The location of Krita's "Add New Layer" popup menu in the "Layers" docker.
The location of Krita's "Add New Layer" popup menu.

There are several filters that we can use to change the color.

In this tutorial, we're going to use Adjust -> HSV/HSL Adjustment, because it lets you change the hue of the image; presumably that's what most people want.

The new filter layer dialog has a list-detail layout. Once you select Adjust -> HSV/HSL Adjustment in the list pane at the left, the settings for the filter should appear in the detail pane at the right.

5: the first thing you see in Adjust -> HSV/HSL Adjustment is a dropdown list button that lets you selected the type of adjustment. Its default setting is Hue/Saturation/Value. Change it to Hue/Saturation/Luma.

Tip: another good option for photography is Blue Chroma/Red Chroma/Luma. We'll learn more why later.

Infographic: color adjustment method comparison in Krita. A base photo of an blue iris with 5 different color adjustment methods applied to change the color of the eye. HSV/HSL (lightness), HSL (luma), and HSI (intensity) with -83° hue. Each made the eye green but left a pink color near the pupil. They also produced slightly different shades of green. Blue-Red Chroma, Luma: -17/-11/0, produced a more "natural looking" green iris without a purple outline. Colorize: 115º hue produced an unnatural, bright green. Photo: Anna Hirsch. Infographic by VirtualCuriosities.com.
A comparison of color adjustment methods in Krita, using turning a green eye blue as example. Observe that in methods that shift the hue of pixels, the blue eye with a brown center becomes green with a pink center. It may be hard to tell from this example, but HSV and HSL had the same result, HS/Luma was slightly lighter, and HS/Intensity was even lighter. The red-blue chroma adjustment method produces the most natural-looking results. Colorize produces a strong but unnatural green. Photo by Anna Hirsch on Flickr.

6: click on the hue bar to adjust the color of the image. Hue is measured absolutely from 0 to 360 degrees. Since this filter changes the hue relative to the current hue, the values range -180 degrees to 180 degrees.

7: click the "OK" button to finish applying the filter.

8: save the image.

Other Filters

Other filters in Krita that are capable of changing the color of the image are:

  1. Adjust -> Color Balance lets you change the cyan, yellow, and magenta balance of colors in the shadows, midtones, and highlights separately.
  2. Adjust -> Desature has the best method to make an image grayscale(How to Make a Photo Grayscale in Krita?).
  3. Adjust -> HSV/HSL Adjustment provides multiple ways to reinterpret the color values of the pixels, such as hue, saturation, value or luma, and change them.
  4. Adjust -> Invert inverts the color values of the pixels.
  5. Adjust -> Levels can be configured to let you change the values of color channels separately.
  6. Adjust -> Color Adjustment (a.k.a. "curves") can be configured to let you change the values of color channels separately as well. This is a good method to change the brightness and contrast of the image in Krita.

Tip: if you aren't satisfied with the results of this filter, you can simply hide the filter layer in the "Layers" docker and create a new filter layer to try another method, and then switch which filter layer is visible to compare the results.

Why Luma?

Krita provides the following "types" of adjustments for the HSV/HSL Adjustment filter:

  1. Hue/Saturation/Value.
  2. Hue/Saturation/Lightness.
  3. Hue/Saturation/Intensity.
  4. Hue/Saturation/Luma.
  5. Blue Chroma/Red Chroma/Luma.

In most cases, an image format will be RGB. This means each pixel has 3 color channels: red, green, and blue. When these 3 are combined, we get colors from black to white, and everything between. Note that there is no "hue" channel or "saturation" channel.

In general, hue, saturation, and value (HSV), or hue, saturation, and lightness (HSL), are calculated from the RGB values. So when the computer shows you HSV parameters, it's showing you the result of a calculation done on the RGB data that is actually stored in the image.

This means that when you change the HSV values, those modifications can't be stored directly in the image either, because the image only contains data in the RGB format. So the computer has to perform the reverse calculation to transform HSV back into RGB. The same is true for HSL, etc.

Note: in 8 bits per pixel per channel, R, G, and B range from 0 to 255, so 100% red, or "1.0" red, is the same as 255 for 8-bit red.

In all methods, hue is a measurement from 0 to 360 degrees, where pure red (255, 0, 0 RGB), pure green, an d pure blue are 0, 120, and 240 degrees, respectively. Purple and pink are higher than 240 degrees, but it "loops back" to red when it reaches 360 degrees, like a circle.

They also all use the same method to calculate saturation.

However, the third component, whether value, lightness, intensity, or luma, is calculated differently depending on the method.

HSV100% value.
HSL50% lightness.
HSI33% intensity.
Luma29.9% luma.

We can guess why these values are what they are. Value is 100% because one component (RGB) is at 100% of its maximum value. Lightness is 50% because pure red is perfectly in the middle between pure black and pure white. Intensity is 33% because if we add the components together 255 + 0 + 0 = 255, and divide by the maximum 255 + 255 + 255 = 765 we're going to get one third because only one component is at its maximum. But what is luma?

Luma is what we want to use for photography.

The first three methods do not care about the actual color of the pixel. Pure red (255, 0, 0), pure green (0, 255, 0) and pure blue (0, 0, 255) will always yield the exact same value, lightness, and intensity values: 100%, 50%, and 33%.

Luma, on the other hand, gives 29.9% luma for pure red, 58.7% luma for pure green, and 11.4% luma for pure blue. If we add these numbers, together 29.9 + 58.7 + 11.4 = 100%. In other words, a white color will have 100% luma, but the amount of blue, red, and green contribute to different amounts of luma.

The reason for this is that these different colors is light being emitted at different wavelengths, and human being are sensitive to these different wavelengths in different ways. Although in the computer the pixel data is in RGB from 0 to 255, that doesn't mean our eyes work the same way. For our eyes, the green of the computer always looks brighter and the blue always looks darker.

Luma takes in consideration perceptual color. If we change the "hue" of a green image to a blue image, for example, most methods will produce a perceptually darker image even though the sum of the RGB components should stay the same. With luma, if we change the hue but don't change the luma, the computer will have to produce a RGB color of different hue with the same perceptual brightness than the original color.

If you take pure red (255, 0, 0) and change the hue to 120 or 240, the other adjustment methods will give you pure green (0, 255, 0) and pure blue (0, 0, 255), but with the luma adjustment you get dark green (130, 0, 0) and light blue (53, 53, 255).

Tip: in Krita, you can use the Settings -> Dockers -> Specific Color Selector to see the values for yourself.

Non-Rotational Hue

Most adjustment methods use relative hue degrees. This means that whatever is the current hue of a pixel, it gets "shifted" to one side or the other. Although this works pretty well in some cases, it does have a huge disadvantage. If you want to change the color of something that changes in color subtly, it will rotate ALL colors toward the same direction by the same amount.

For example, if something is red and yellow, and you turn red into blue, the yellow will turn into purple.

There are two ways to fix this.

The simplest method is to use the "colorize" option on the adjustment settings. This will make all pixels the same hue. One disadvantage of this is that making everything exactly the same hue can look a bit unnatural. You may be able to fix this a little by decreasing the opacity of the filter layer.

Another method is to use Blue Chroma/Red Chroma/Luma. This doesn't have hue and saturation, instead we get blue chroma and red chroma. The idea is essentially the same: green contributes the most amount when we calculate luma, so in this method, the green is "built into" the luma, and when red and blue chromas are negative, the only thing left is green.

Tip: in Krita it's possible to change the color space of the image from RGB to LAB or YCbCr through Image -> Convert Image Color Space.... When an image uses these color spaces, the pixel data doesn't have RGB values, but L, a, b values, or Y, Cb, Cr values. In both cases, one component is the luma while the other two are the chroma. If you're doing a lot of color work on an image, it's a good idea to use this color space instead. Note that changing color spaces is a destructive action: you shouldn't change from one color space to the other over and over again, pick one color space and work with it until you need to export the image.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *