# Thilina's Blog

## Chroma Keying

When we watching TV programs and some movies some times we amazed by seeing the background of the presenter. Some times in front of a fantasy location or with various moving objects etc.

Technology behind this magic is called chroma keying. In chroma keying uses a special kind of back screen which reflects the light to the direction which to the screen. In the camera side as in the picture, around its opening green or blue colour LEDs were set as a light source. Selecting this blue or green colour is due to a special reason that is they are the less related colours to the human complexion. Most of the time this colours are selected as Green (0,255,0) and Blue (0,0,255)  in 8-bit RGB colour pallet.

During the recording all the background is replaced with the source colour due to the direct reflexion of the back screen. In chroma keying filter it removes all Green or Blue pixels as set in chroma level and replaces all them by the feeded frame that is a still image or a video.

In simple mathematic brief in chroma filtering can be described as follows, note that this is not exactly happens in the filter but only for understanding its behaviour.

Let the  camera input as ‘C’, Chroma level colour as ‘t’ , provided back image as ‘f’ and the output frame as ‘I’.

First we can create a logical mask ‘M’ which contains 1’s for the pixels which are equal to the chroma level.

Then we can easily generate the resulting frame by masking ‘f’ by ‘M’ with adding the masked image of ‘C’ by ‘~M’.

This algorithm you can simply implement on MATLAB.

2010 November 18 -

1. Dude dnt knw wt dis is abt . bt still its AWESOME 😀 keep t goin 😀
all the best 😀 😀
cute butterfly pics bdw 🙂 🙂

Comment by Rukmal Fernando | 2010 November 22 | Reply

2. Good Article Malli… 🙂

Comment by Chakshika | 2010 November 28 | Reply

3. could you provide sample codes for learning?
Thank you.

Comment by Michael | 2011 January 22 | Reply

• I already added sample codes on Chroma keying, Please check chroma keying MATLAB implementation articles.., Thank you for the comment..!

Comment by thilinamees | 2011 January 22 | Reply