Subsections


Chroma Key (HSV)

Chroma Key (HSV)9 (figure 10.30) replaces a color with another color or transparency using HSV variables; it is frequently used to remove a color from a video to composite with another image. This process is generally referred to as green screen or blue screen process (because of the background color that is keyed out). More information: http://en.wikipedia.org/wiki/Chromakey

Figure 10.30: Windows config for Chroma Key (HSV)
Image chroma-key-hsv


Requirements

The subject in the movie should have a good background. The lighting is crucial and good lighting during production will save you time with much less effort than in post-production. Another tip is to use a low-compressed, intraframe codec with as high a color depth as possible. In case of YUV-type source signal, it is better to have subsampling 4 : 4.4 or 4 : 2 : 2. Here we assume that we have a good video, filmed on green (or blue) screen that we want to use. Important: Make sure you are using a color model that has an alpha channel, such as RGBA8, RGBAFloat, YUVA8. To change color model, go to Settings Format Color Model.


Usage

As in any other effect, add it to the timeline in the main window. You can tweak each parameter in order to improve the keying.

To understand how the plugin parameters work, we need to refer to the HSV color wheel (foreground color) in figure 10.31. Coinsider that this is an abstract example; in the real world we will be dealing with much more complicated masks.

Figure 10.31: Various parameters in the 'Color' and 'Key Parameters' sections.
Image hsv_color_wheel

The left half has Saturation from 0 (in the center) to 100 on the edges. An example of a green screen is shown here. The right half has brightness from 0 (center) to 100 on the edges. The example of a blue screen is given here. The key color is the radius of the wheel, and its angle determines the hue. The Hue Tolerance is the arc of a circle (a wedge) that includes the radius. The wedge is the color range (mask) that we want to eliminate by keying, its shape is precise and easy to understand. The Brightness are the inner/outer extremes of the wedge; if the inner value (Min) is 0, then it coincides with the center point, if the outer value (max) is 100 then it coincides with the arc on the circumference. With intermediate values we will have masks similar to the one shown in the figure. Min Saturation is the distance from the center, along the Hue radius, from which we want to impose saturation with the value 0. It will be the value from which keying starts. Saturation Offset is an additional cut we make to the inner part of the wedge from the Min Saturation value. All of these adjustments allow us to establish a range of colors (Mask) that perfectly matches the background (the wedge in the example in the figure) that we want to eliminate. This is a precision operation, and it is not rare to return to the parameter combination several times to refine the mask.

Start with Hue Tolerance at 10%, Min Brightness at 0, Max brightness at 100%, Saturation offset at 0, Min Saturation at 0, In Slope at 0, Out Slope at 0, Alpha Offset at 0 (that’s mid-way through), Spill Threshold at 0, Spill Compensation at 100%. At any time, you can check what the Mask looks like by clicking on Show Mask. This will output a black and white image of the mask (matte).

        Color section

In this section of the configuration window, you choose the key color and have the ability to see the mask created.

Color...
Select the key color (green, blue, etc) using the color wheel or the color picker. Remember, only the Hue matters, not Saturation or Value. To use the color picker, click on the color picker icon in the Compositor window, then click on the color you want in the Compositor window. Finally in the Chromakey (HSV) parameters window, click on Use Color Picker. Remember to disable ChromaKey (HSV) plugin when using the Color Picker on the Compositor window.
Show Mask
The plugin does not create a true matte in the alpha channel, but creates a mask. Activating this option will show the foreground as a white (opaque) shape while the background in black (transparency). You will be able to control the extent of the mask, any jagged edges, small black areas within the mask or small white areas within the foreground, which are to be removed, etc.

        Key parameters section

In this section we expand the mask to a range of colors close to color key and refine the selection by also taking advantage of brightness and saturation.

Hue Tolerance:
Because there are slight variations in lighting in real cases, the background will not be in a uniform key color hue. Increase or decrease the Hue tolerance to mask out the background. If there are dark spots that are keyed out that shouldn’t be, it can be corrected later (With the Mask tool, this operation is called the Garbage Matte).
Brightness:
It allows the color range (Mask) to be better defined by exploiting the differences in brightness between background and foreground. This could be referred to as a Luma Key within the Chroma Key. Increase Min Brightness so that only the background is masked out, and not parts of the foreground. You can also reduce Max Brightness if some clear areas are keyed out (useful for very dark backgrounds).
Saturation:
It allows the color range (Mask) to be better defined by exploiting the differences in saturation between background and foreground. Since the best results are obtained by keying pure colors, it may come in handy to eliminate the less saturated colors (proper to the foreground) while leaving the more saturated colors (proper to the background, i.e. Green/Blue Screen) to the keying action. Increase Min Saturation so that only the background is masked out, and not parts of the foreground. Saturation Offset can be used to change this, because it acts similarly to Min Brightness. It could be said that Min Saturation concerns only the key color, while Saturation Offset concerns the range of Hue tolerance. But it is best to start by leaving it at 0.

Check what it looks like at this stage, your mask should be pretty clean. Toggle Show Mask to check what it looks like, it should be OK. If not, repeat steps 1to4 to get a better key. The rest of the controls are useful to smear the mask to help compositing later on. They will help you to make your key look much cleaner.

        Mask tweaking section

In this section you intervene on the already created mask with edge smoothing and transparencies.

Slope:
For now, the mask is a full on/ full off mask that can be really harsh on the edges and not necessarily what you are looking for. In Slope and Out Slope will help you to smooth that key. In Slope it acts on the inner side of the edges by grading them with keying (background) colors. It leaves more colors in the mask. Out Slope acts on the outer side of the edges by grading them with the foreground colors. It takes more colors out of the mask. Basically, the colors that are borderline in the mask will see their alpha channel reduced by half instead of being completely on or off.
Alpha Offset:
This control offsets the whole alpha channel by some amount (from -100=full opacity to +100=full transparency). Be sure to know what you are doing if you change it from the default value of 0.

        Spill light control section

In this section we try to make halos, reflections and parasitic lights present on the foreground less noticeable.

spill light control:
This step helps you remove the green or blue halo around the edges of the mask. It does so by removing the saturation of pixels of the foreground that have a similar hue to the key color (turning them into grey instead of green or blue). The hues to be desaturated are set with Spill Threshold, the degree of desaturation is set with Spill Compensation. In order for Spill compensation to work, Spill Threshold must be > 0. If you start with Spill Compensation at 100%, slowly increase the Spill Threshold until the remaining green or blue areas turn grey. Then reduce Spill Compensation until the image looks good.

Now the mask is probably still very harsh, so just below the Chromakey (HSV) plugin, add a Blur effect, and select only the Alpha channel, with a radius of 2 or 3 (more if you really want to soften the edges). This will significantly help the keying.



Footnotes

... (HSV)9
Credit for Plugin by Jerome Cornet http://jcornet.free.fr/linux/chromakey.html
The CINELERRA-GG Community, 2021
https://www.cinelerra-gg.org