Thilina's Blog

I might be wrong, but…

Chroma Keying MATLAB Implementation 3.0


In my previous articles on chroma key implementation on MATLAB (Chroma Keying MATLAB Implementation 1.0 and 2.0), I explained how to key two images using a simple image segmentation method called ‘Image thresholding’ and to key an image and a video. In this article I’ll try to extend above to implement on MATLAB simulink.

There are two approaches to implement these on MATLAB, first is to implement chroma key using the MATLAB embedded function block and the second is to implement above functionality using basic simulink blocks.

Using MATLAB simulink embedded function

For the implementation arrange the Simulink blocks as below. Image from file block can be found in simulink video and image processing tool box under the source category and Video viewer under sink category. Matrix operation blocks can be found in Signal processing tool box and the Embedded MATLAB function can be found under Simulink user defined functions. And set its parameters as described below.

clip_image002

Continue reading

2010 December 29 Posted by | Chroma Keying, Image Processing, MATLAB, Technology | 9 Comments

Chroma Keying MATLAB Implementation 2.0


In my previous article on chroma key implementation on MATLAB (Chroma Keying MATLAB Implementation 1.0), I explained how to key two images using a simple image segmentation method called ‘Image thresholding’. In this article I’ll try to extend above result to key a foreground video with a background image. Please note that this implementation can be use to process a video after saving it or post processing manner.

During this implementation I used an *.avi video file ‘movie.avi’, which has the chroma keying properties; a video taken in front of a blue screen as my foreground video and ‘background.jpg’ as my background image.

clip_image002 clip_image004

Opening a movie to MATLAB workspace can done by using the command ‘mmreader ()’. The command creates a multimedia reader object on MATLAB workspace. You can read more on this command by typing ‘doc mmreader’ on MATLAB command prompt.

Continue reading

2010 December 16 Posted by | Chroma Keying, Image Processing, MATLAB, Technology | 9 Comments

Chroma Keying MATLAB Implementation 1.0


In my previous article I discussed the major concepts on chroma keying. In this article I will discuss a method for use chroma keying principles to key two images in to a single image. For the implementation we need two images which can use as background and foreground images. I select ‘background.jpg’ and ‘foreground.jpg’ as my background and foreground images for the keying operation. Note that the foreground is the image which you stay in front of that special reflecting screen.

    clip_image002 clip_image004

We can add those two images in to MATLAB workspace by using following commands.

imBg = imread(‘background.jpg’);

imFg = imread(‘foreground.jpg’);

As we can see the foreground major colour is blue, therefore we have to mask the corresponding blue colour from the image. In order to perform this operation, we need to create a mask with colour thresholds. The ‘key’ variable contains the corresponding RGB colours for the above colour filtering operation.

Continue reading

2010 December 3 Posted by | Chroma Keying, Image Processing, MATLAB, Technology | 21 Comments

Interpolation Based method for Directional Derivative Calculation in Image Processing 1.0


Directional derivative calculation can be done by using a number of kernels in image processing. Most of them are fixed and can only use in single direction. This article attempts to discuss and use a geometrical model to as a solution for this situation.

Considering the gradient calculation in image processing, since it is discrete domain, calculations are done by forward and backward differences. Therefore co-efficients of pixels can directly use for built a kernel which can convolve with a given image to determine the gradient.

Consider two pixels f(x,y) and f(xr,y) of an image which are in r direction with |r| distance. Then the directional derivative can be written as;

clip_image004

clip_image002[4]

Model discussed below attempts to specify a virtual pixel D(xr,yr) which can use to determined the directional derivative along the vector r. Consider following 9 pixels.

Assume we need to calculate the directional derivative through Q in θ direction with x axis.

Continue reading

2010 November 25 Posted by | Image Processing, MATLAB, Technology | 4 Comments

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.

Continue reading

2010 November 18 Posted by | Chroma Keying, Image Processing, MATLAB, Technology | 4 Comments

%d bloggers like this: