Green screen / chroma key

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
sn0wball
Posts: 2
Joined: 2012-05-11T01:31:08-07:00
Authentication code: 13

Green screen / chroma key

Post by sn0wball »

Hello,

I'm trying to process the following image in order to remove the green screen background and replacing it with any another image:
http://img576.imageshack.us/img576/747/ ... sample.jpg

I have no influence on the quality of the green screen or the capture itself.

As I'm new to Imagick I ended up trying the command example from the docs, such as
- http://www.imagemagick.org/Usage/masking/#difference
- http://www.imagemagick.org/Usage/photos/#green_screen
- http://www.imagemagick.org/Usage/photos/#chroma_key

Also the usual -fx algorithms for green screening didn't work out for me:
http://www.multipole.org/discourse-serv ... 8b7#p74744

The results are far away from a usable mask which I would need in order to make an almost perfect cut-out.
Expected result (via Photoshop): http://img818.imageshack.us/img818/3960 ... result.jpg
Example background image: http://upload.wikimedia.org/wikipedia/c ... t_time.jpg

The processing will have to be done on multiple images with a similar green screen.

Any help or hint is appreciated.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Green screen / chroma key

Post by Bonzo »

Woops - nothing to add
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Green screen / chroma key

Post by fmw42 »

Can you tell us how PS does it? Not everyone has or uses PS! Is there some PS tutorial on the topic?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Green screen / chroma key

Post by fmw42 »

try this. Adjust the fuzz value as desired.

convert greenscreensample.jpg -channel r -separate +channel -fuzz 1% -fill black -opaque black -fill white +opaque black greenscreensample_mask_1.gif

Then use

convert backgroundimage foregroundimage maskimage -compose over -composite resultimage
sn0wball
Posts: 2
Joined: 2012-05-11T01:31:08-07:00
Authentication code: 13

Re: Green screen / chroma key

Post by sn0wball »

I use the technique used shown here http://www.youtube.com/watch?v=CpJ8E4sq ... re=related.
So Photoshop uses a mask as well, which is able to reduce noise of unclean green screen in the background.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Green screen / chroma key

Post by fmw42 »

Once you have the mask, you can clean it up often times using -morphology open or close depending up white on black or black on white

see
http://www.imagemagick.org/Usage/morphology/

You can also feather the edges.

see
http://www.imagemagick.org/Usage/masking/#difference
http://www.fmwconcepts.com/imagemagick/ ... /index.php
Post Reply