Skip to content
This repository has been archived by the owner on Feb 10, 2021. It is now read-only.

asiryan/Real-time-chromakey

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 

Repository files navigation

Real-time chroma key filter

MATLAB implementation of fast and accurate chroma key filter based on histogram.

Introduction

Chroma key compositing is a visual effects/post-production technique for compositing (layering) two images or video streams together based on colour hues (chroma range). The technique has been used in many fields to remove a background from the subject of a photo or video – particularly the newscasting, motion picture, and video game industries. A colour range in the foreground footage is made transparent, allowing separately filmed background footage or a static image to be inserted into the scene. The chroma keying technique is commonly used in video production and post-production.
The aim of this code example is to extract the green background, also called chroma key, and replace it with the background from a different image. In fact what we're doing is keying out a black and white mask from the green component of the foreground image and using it to mask.

MATLAB

Download matlab source folder and open chromakey.m file. Define script params and run.

background = 'images/background/PANA0701_a.jpg'; % background image destination
foreground = 'images/foreground/PANA0701_b.jpg'; % foreground image destination

Example

This script automatically calculates optimal threshold value of histogram and applies chroma key filter to defined images.

>> chromakey_histogram
Chromakeing
Left point: 69
Right point: 218
Threshold: 148
Normalized threshold: 0.58039
Done

Figure 1. Background and foreground images

Figure 2. Histogram

Figure 3. Blended image

Other implementations

UMapx.NET - Digital signal processing library for .NET Core and .NET Framework. Fast and optimized.

Releases

No releases published

Packages

No packages published

Languages