• Home
  • Nuke Plugins
    • Luminance
  • Matte Extraction
    • Difference Matte
  • Fluid Dynamics
    • Krakatoa Ink
    • Realflow - Solid to Liquid
difference matte title image

The difference matte is a method used for producing mattes from bluescreen images. Though it should be noted that the colour of the screen is not important, so long as it is different from the foreground object.

It is interesting that despite the primary school mathematics of this method the results are often better than those you see coming from keys being pulled from After Effects. Though I do admit that poor results are more likely to be due to user error (no use of garbage matte etc) than the software itself.

First of all. Thanks to Steve Wright for the blue screen images.

So anyway. How does this work? Well as I said the maths here is as remedial as it gets.

G - R

where G = Green Channel p/pixel and R = Red Channel p/pixel.

To get the raw matte extracted really is as easy as that. Though this is not the final matte as I shall demonstrate. It should be noted that most of this stuff can be done using Image -> Calculations in Photoshop, the reason I am using MATLAB is for the output of coherent graphs and for further study.

Here is the image to extracted. All channel traces are taken from line 200, as this is being done in MATLAB that is just above the shoulders, with line zero being at the top of the image.

difference-matte-extraction

This is quite a good image, the background is perfectly lit and there is very little spill. The lack of spill is very obvious in the dual channel trace seen later.

 

Below is the trace for the green channel, you can clearly see the foreground object from the dip in the values at around 180 pixels in and then rising back up around 380. It is also apparent that while the background looks uniform. It is not! The reason for this is noise in the image, there will be much more of this in the blue channel.

** Please feel free to not consider the color scale at the right of the graph until the final raw matte extraction and scaling.

MATLAB-difference-matte-green-trace

Below is the trace for the red channel on the same line. Likewise you can see the foreground through the lack of red in the background and an increase in the foreground, all taking place in the same space as the green channel.

MATLAB-red-channel-trace

Below is the two channels plotted together and colour coded for brevity. It is here you can see why it is there is hardly any spill in the bulk of the foreground (though there will be some on the edges). The values for the green channel never rise above the values for the red channel.

Here is the result from the subtraction of the red channel from the green.

raw difference matte

You can see that the subtraction has push the foreground into negative values, as most graphics programs do not allow for negative values the resulting image would have values for the foreground clipped at zero. As is happens this is not a bad thing. This can be inverted and the clipped blacks become clipped whites, both whites and blacks can then be scaled to produce a defininite matte. This result can then be multiplied against the original image to produce transparency in the green area.

This method can certainly be refined and it is not aparent from this example where the method falls down, though you can see how in images where there is a considerable quantity of spill this would be extracted too. Use of a more refined piecewise function can help with this problem.

raw difference matte

Scaled Version

You can see that the scaling for the most part has worked a treat. However, there are some artifacts left over on the torso (right side). Though this could be cleared either with a simple seach and replace alogorithm (MATLAB case) or roto it out (graphics program case). Either way looking at the detail still remaining after extraction it is obvious that this method is both simple to implement and produces far superior results than say using the standard keyer and that matte choker thing in After Effects.

scaled difference matte

 

Below is the result from multiplying the extracted matte by the original bluescreen image. You can see where there is still some spill around the edges of the arms and the hair. To remove this a spill map should be produced before matte extraction.

difference matte multiplied result