How To Remove An Image Background Using Gimp

How To Remove An Image Background Using Gimp

There are a number of ways to remove the background from a Second Life image using Gimp, but the method I will show here is possibly the most effective. Once you have the image saved to your PC  the rest is quite quick and easy. This tutorial will also be helpful in demonstrating to a Gimp novice just how effective layer masks can be.

Before we begin to remove the image background however, we first need to do some preparation for taking the snapshot in Second Life.

Taking The Second Life Image

Before taking the image there are a few steps we need to take:

1/ Choose a neutral background for your avatar to pose against, such as one with a single, even colour. This will make it much easier to remove.

2/  Position your avatar on a modelling poseball, ie, one that will keep your avatar completely still. 

3/ Position the camera ready to take the snapshot. It is important not to move your avatar or the camera until the steps below have been followed.

How To Remove An Image Background Using Gimp: configuring settings

4/ Open up the preferences window by pressing CTRL-P then under the graphics tab deselect Local Lights, Basic Shaders, and Atmospheric Shaders. Click OK to close Preferences.

5/ From the screen menu click on World > Environment Editor > Sky Presets > New Preset.

How To Remove An Image Background Using Gimp: Environmental Editor panel

6/ Towards the bottom of the panel, move the Gamma slider all the way to the left. Enlarge the image above to get a clearer view if you need to.

How to remove an image background with Gimp: settings

Your screen should show look something like the image above, with your avatar silhouetted against a white background. 

The setting you have just created in the environment editor will be useful for every snapshot you take and intend to remove the background from, so give it a name and then save it.

7/ Take a snapshot of the monochrome image.

8/ Now restore the daylight setting back to default, and re-select the lighting settings under Preferences.

9/ Take a snapshot of your avatar, remembering not to move the camera position.

Once the snapshot has been taken, you can hop off the poseball and move the camera. You should now have two snapshots; one that is a monochrome image similar to the one  above and another of your avatar in the same pose as the silhouette.

Removing The Background In Gimp

Now that you have the two images to work with, the rest is quite straightforward as Gimp will do the hard work for us:

1/ Open the image of your avatar in Gimp and then add the monochrome image as a layer (File > Open as Layer).

2/ You can crop the images if you want by using the Rectangle Select tool to drag a border around the portion of the image you want to keep, then selecting Image > Crop Image to Selection.

How to remove an image background with Gimp: Inverted image

3/ With the monochrome image the top layer, and the active layer select Colors > Invert. The silhouette should now be white against a black background.

How to remove an image background with Gimp: Adjusting brightness and contrast

4/ Now Select Colors > Brightness-Contrast, and in the panel that opens move the contrast layer to the right until no detail can be seen within the white outline of the avatar. Click OK.

Adding A Layer Mask

How to remove an image background with Gimp: Adding a layer mask

5/ In the Layers panel, right click on the top layer (which should be the monochrome layer), and from the drop down menu select Add Layer Mask. This should be about half way down the menu. From the window that opens select Grayscale copy of layer. Click the Add button.

6/ In the layers panel, right click on the monochrome layer again, and this time from the drop down menu select Mask to Selection.

How to remove an image background with Gimp

7/ In the image window click Select > Shrink. In the Shrink Selection window type in '1' so that the selection will shrink by one pixel. This is to (hopefully) ensure the avatar image won't have untidy edges when the background is removed.

8/ Now hide the top layer in the Layers panel by clicking on the eye icon to the left of it, and make the avatar layer the active layer.

Right click the avatar layer and from the drop down menu select Add Layer Mask. The Add Layer Mask window will open again, but this time choose Selection and click OK.

9/ In the Layers panel create a transparent layer by clicking the icon below and to the far left of the layers. Then use the green arrows to place it below the avatar layer.

10/ Right click on the avatar layer and select Merge Down from the drop down menu.

How to remove an image background with Gimp: Image with background removed

The avatar image should now have a transparent background, with the original background removed. You can now add any background to the image you like.

How to remove an image background with Gimp: Image: Image with replaced background

In the example used here I added a gradient on a new layer as a background image for the avatar. Then with the avatar layer the active layer I selected Filters > Light and Shadow > Drop Shadow, to create the shadow effect.

Once you get to grips with these simple steps, removing the backgrounds from your Second Life images will take no time at all. However, this technique is limited to those snapshots you know in advance you will be removing the backgrounds from, so a few basic preparatory steps need to be taken before taking the snapshots.