Open Source

How to easily key out green screen in The GIMP

Jack Wallen shows you how to easily "key out" a green screen from a still image in The GIMP.

GIMP

If you work with The GIMP enough, you'll eventually need to key an image from a green (or blue) screen and place that image into another layer. Chromakey (or green screen) has been a fundamental element in film for years. Few people know that same technique can be applied to graphics design for very easy image manipulation.

I use this technique every day with The GIMP — for article graphics, book covers, and just about any image that includes layers. With that in mind, I want to show you how to easily "key out" an image with The GIMP.

I'll start with a basic image of me standing before a green screen (Figure A).

Figure A

Figure A

This is me, cut from a video.

What we're going to do is remove my head and shoulders and overlay them on a background. It's not a major challenge, but there are a few steps, and it can be a bit time consuming (depending on the complexity of the image). Let's walk through the steps.

In the image with the green screen, you must first add an Alpha Channel. Why? The Alpha Channel adds a transparent layer to the images. Without this Alpha Channel, the cutting from the original image will include a fill-in color (Figure B).

Figure B

Figure B

With alpha channel above, without below.

Note: I'll be demonstrating this with The GIMP in Single Window mode. To switch to that mode, click Windows | Single-Window Mode.

With the image, make sure you have the Layer dialog available (click Windows | Dockable Dialogs | Layers — or [Ctrl]+[L]). From that dialog, right-click the layer of the image and click Add Alpha Channel. You'll know the Alpha Channel has been added, because the name of the layer in the Layer Dialog will be in bold.

With the Alpha Channel added, select the Color Tool from the toolbox, and then click on the green in the background. This will select the color, which you can then click Edit | Cut. Now, here's the big issue when working with chromakey. If your screen isn't perfectly lit, you'll get shadows. What does that mean with The GIMP? It means you'll have to go back and keep selecting and deleting until all that remains is the image you want (Figure C).

Figure C

Figure C

Having to delete shades of the key.

What you should eventually see is shown in Figure D.

Figure D

Figure D

The key has been removed.

At this point, you can now copy and paste that image over your background. Before you do that, you'll want to add another layer over the background image, so that you can better manipulate the copied layer. The final result is much better than if you'd simply attempted to remove the key with the erasure tool (Figure E).

Figure E

Figure E

The final results.

You might have to go back with the erasure tool and do some minor cleanup. If the green screen was done well (properly lit and filmed), you'll have very little to do after the removal of the key. If there are shadows, some cleanup will be required. One thing you should also make note of is to alway save images with Alpha Channel transparencies as .png ( because .jpg doesn't support transparency). You should also always first save in the native .xcf formate to preserve layering.

The GIMP is an incredibly powerful tool. With a solid foundation of this image manipulation application, there's very little that you can't do.

Do you use The GIMP? If not, what prevents you from doing so? Let us know in the comments below.

About Jack Wallen

Jack Wallen is an award-winning writer for TechRepublic and Linux.com. He’s an avid promoter of open source and the voice of The Android Expert. For more news about Jack Wallen, visit his website jackwallen.com.

Editor's Picks

Free Newsletters, In your Inbox