Skip to content

prtvi/green-screening-implementation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Green Screening Implementation

This a simple implementation of the green screening process for images implemented in Python and MATLAB. Green Screening / the Green Screen algorithm is often used to change the background behind an object with a background of our choice. This process is widely used in applications where the background needs to be changed.

About the Green Screening algorithm

The process requires two images as it's input - foreground image and background image. The foreground image must have an object placed over a green background. The background image can be any image of our choice. These images should have the same dimensions. The output we get will have the same dimensions as well.

During the process, a new image (say output) is created. The pixels of the output image are taken depending on the following process: the algorithm checks every pixel of the foreground image for the intensity of the green color. If the intensity of the green color is beyond a certain threshold (say 240), then the output image will have the corresponding pixel taken from the background image, else the corresponding pixel is taken from the foreground image. This way the pixels are populated in the output image. This is the working of the green screen algorithm.

File Description

  • green.m: Run the process in MATLAB.

  • green.py: Run the process in Python. Requirements:

    • PIL (pillow) imaging library
    • Numpy

Requirements

  • An image with an object over a green background as shown below: Foreground (images/fg.png):
    Foreground

  • A background image (images/bg.png):
    Background

  • Make sure both images are of the same dimensions.

Output achieved

Here is the output achieved with a threshold of 235:

Output

Other links

Click here to check out my other projects

About

Green screening implementation in Python and MATLAB

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published