Keying, also known as chroma keying or color keying, is the process of converting a specific range of colors into the alpha channel, to show the background footage when layered. The following screenshot shows an example of this concept:
A clear understanding of the differences between value and luminance is very essential in compositing since the human eye is more sensitive to luminance than to colors. It turns out to be even more crucial while keying, since everything in keying is dependent on how you start the process, with respect to a specific channel in a specific color space. To explain this in detail, the following screenshot will be used, which contains different tones with at least one of the RGB components having a value of 1:
The desaturation of an image will result in displaying the value of the image. The value displays the maximum value in between the RGB components. Since the input image has the value as 1 in any one of the RGB channels, the result will be a full white image signifying a value of 1 in any of the colors, existing as the maximum value in any of the channels.
When we see the colors, we can perceive perceive blue as dark color compared to Cyan and Yellow as bright compared to red. This variation in brightness that we perceive is called the luminance of the color.
Luminance of an image can be displayed using the RGB to BW node. The following screenshot illustrates the luminance levels of colors when using the RGB to BW node:
Luminance of the same image, when displayed as a Y channel in the Separate YUVA node, also shows the variation of brightness in colors, as shown in the following screenshot:
The following screenshot shows the luminance of the same image using three different modes of the Separate YCbCrA node:
It can be observed that the luminance displayed in all these models is not the same since the weightage of 100 percent for each channel in RGB is different in each model. So, the model to be chosen depends on the requirement.
After having a good understanding of luminance and the different models available, an apt model can be chosen as a starting point in keying, where the color ranges to be keyed are close to blacks or whites in a specific color model.
The success of keying green/blue screen footage depends on the following factors. These have to be inspected before proceeding to keying.
The Difference Key node creates a mask based on the difference between the inputs plugged to the Image 1 and Image 2 sockets. Tolerance and Falloff can be adjusted to fine-tune the created mask. The following screenshot shows an example using the Difference Key node to modify the flower tone:
The Distance Key node works similar to the Difference Key node but with a different algorithm. Tolerance and Falloff can be adjusted to fine-tune the created mask.
The Luminance Key node creates a mask based on luminance of the input plugged to the Image socket, controlled by Low and High handles. This node works as per the YUVA color space. The following screenshot shows an example using the Luminance Key node to modify the flower tone:
The Color Key node creates a mask based on the sampled color in the key color area. HSV sliders can be adjusted to the generated mask.