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

  • · For Image From File blocks, Constant blocks and Transpose block, set signal output data type as ‘uint8’. The values for the constants may differ with your back-screen colour, for my images I use [130 170 118] RGB as the filtering margin.
  • · For Matrix Concatenate block, set parameters as below.

clip_image004

  • · Finally for the Embedded MATLAB function block, add the code as below.

clip_image006

It is the same code I used in my previous articles, but I removed the code lines which I used to select chroma majoring colour and only used the operation on blue backgrounds. Input images are as below

background          foreground

The resulting images will be as below.

clip_image008

For the Chroma keying on Video you can just replace the Image From file blocks from From Multimedia flie blocks in Image Processing tool box or From Video Device in Image Acquisition tool box. Resulting video is as below, you can also note how much slow is the process.

Using MATLAB simulink basic function

For the implementation arrange the Simulink blocks as below.

clip_image010

In here I mapped the above code to appropriate Simulink building blocks. Results are same as above and For the Chroma keying on Video you can just replace the Image From file blocks from From Multimedia flie blocks in Image Processing tool box or From Video Device in Image Acquisition tool box. Resulting video is as below; you can also note how much slow the process is.

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

9 Comments »

  1. gindara gindara😀
    passe kiyapan mokakda mey scene eka kiyala😀😀

    Comment by Rukmal Fernando | 2010 December 29 | Reply

    • he hee😀😀
      sthutheeee🙂

      Comment by thilinamees | 2010 December 29 | Reply

  2. good good

    Comment by Shamika | 2010 December 29 | Reply

    • Thanks bro🙂

      Comment by thilinamees | 2010 December 29 | Reply

  3. I should try this🙂

    Comment by අකිල | 2010 December 29 | Reply

    • yeah…,
      when needed, I got the *.mdl with me🙂

      Comment by thilinamees | 2010 December 29 | Reply

  4. Great work man…

    Comment by Madushan | 2010 December 30 | Reply

  5. what happened??? fairy went black n white?? haka haka.. this should be something really clever or really dumb so i dont understand.. :):)

    Comment by lodperera | 2010 December 31 | Reply

    • Sorry Oshada…,
      I haven’t uploaded the input images to the post…
      Just updated it..,
      Sorry again, and thanks a lot for notifying it🙂

      Comment by thilinamees | 2010 December 31 | Reply


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: