Home About Calender Contact Advertise

Wednesday, 27 April 2016

How To Remove The Background From An Image Using Gimp


In an earlier tutorial I explained one method of removing an image background using Gimp, and here I'll show an alternative way of achieving the same result. Although this is a quick and easy way of removing the background, the quality of the final result may depend a lot on the image you start with. For instance, it is best to start with a large picture and resize it later. As a guideline, the image I used for this tutorial was 3000 x 3000px. 

One more thing to keep in mind with this method is, you'll need to start with a background that has an even, uniform colour rather than something scenic. There is also a video version of this tutorial at the bottom of the page for those that find videos easier to follow. Now to get on with the tutorial

1/ Open Gimp and load the image you want to work with.

2/ From the Toolbox panel select the Colour picker (the eye dropper icon), then click on the background of the image. 

3/ Under the Toolbox icons there are two overlapping squares, one black, the other white. As you selected the background colour from your image, the upper square now will show that colour. Click on this upper square and a window similar to the above will open. Drag your cursor over the HTML colour notation and copy the six digit number. You can now click on OK.

4/ In the image window select Colors > Color to Alpha and a window similar to below will open.

The colour to alpha default is white so we want to change it to the background colour of the image. To do this click on the white area in the window, which will bring up another window, as below.

5/ In the HTML notation area of this window paste the number you copied earlier. The result should be the background from the image becomes transparent.

As you can see from the above image this process removes the selected colour from the entire image, and not just the background. However, we can re-add that colour to the subject.

Re-Adding Colour To The Subject

6/ The first step we now want to take is to give the subject a solid appearance. This will make the colours seem very wrong but right now thats not important. Make sure the layer is highlighted and hit the copy button  (the icon third from right at the bottom in the image above), several times. For this image I created a total of nine copies. 

7/ For the last two layers click on the eye icon to hide them. Now place your cursor over one of the visible layers and hit the right mouse button. From the drop down menu select Merge Visible Layers, (Its towards the bottom of the drop down menu). In the window that opens click the  Merge button. 

You should now have three layers, and in the image window a rather discoloured looking image.

8/ Ensure the Merged layer is the active layer. Right click on it and from the drop down menu select Alpha to Selection, (see image below).

9/ Now create a new layer by clicking on the first icon below the layers window and create a transparant layer. Make sure this new layer is now the active layer. The merged layer can now be deleted.

In the Toolbox panel you should see that the active colour is still the background colour we just removed from the image. Select the Bucket Fill tool highlighted above. Now click within the outline you'll see in the image window to fill it with the colour.

In this example I wanted the filled colour to be as solid as possible, so I created copies then merged them, following the same process we used earlier. We should now have three layers: the layer filled with the background colour, and two layers of the subject.

10/ Now make one of the hidden layers visible by clicking on its eye icon in the Layers Panel then move it above the filled layer by using the green arrows just below the layers area. Right click on the top layer and from the dropdown menu select Merge Down. You should now have two layers.

Removing Remnants Of  Background Colour From The Image

Once the background has been removed you may still see around the subject a slight outline of the original background colour, but the next few steps will fix that. The image should still have a selection around it (the dotted line) and we'll need this. If however you've already hit Select > None, just create another alpha to selection using the same method you did earlier.

11/ From the image window menu click on Select > Shrink.

12/ The small window that appears allows you to shrink the selection area by a given number of pixels. In this example one pixel should be enough, but this may be different for your image, so a little trial and error may be needed. After you've chosen the amount of pixels to shrink the selection by hit the OK button.

13/ Now go back to the Select menu and this time hit Invert from the drop down menu. This will mean that everything that was outside of the original selection is now selected. Hit the Delete key on your keyboard to delete the selection. Any unsightly outline to your subject containing the background colour has now been deleted.

Touching Up The Completed  Image

This is essentially all that is involved in removing the background from a Second Life image, but you may find there are still some areas that need touching up. In this example, looking closer at the hat feather shows that it still contains the green from the background. In the next few steps we'll see how this can be fixed.

The following images have been given a white background to make them clearer. When you follow these steps however, the background in the Gimp image window will have the checkerboard background that indicates transparency.

14/ From the Toolbox Panel select the Eraser tool, then in the image window zoom into the area you want to work on, in this instance its the feather. Carefully erase the feather trying to keep a clean outline to the hat.

15/  In the Layers Panel hide the layer with the erased feather by clicking its eye icon, then make the remaining layer visible and ensure it is now the active layer. From the Toolbox select the Paths tool as shown above.

16/  In the image window use the Path tool to create a path around the feather, clicking your left mouse button when you want to change direction, and finishing where the path began. From the bottom half  of the Toolbox Panel hit the Selection From Path button and the selection should turn into a line of what is known as marching ants, (it will essentially look the same as the dotted line from the earlier alpha to selection we made).

17/ From the image window menu hit Select > Invert and then hit the delete key. The area you originally selected should be all you see of the layer. You'll see the colour of the feather should be quite clear, but to give it more strength you can create a copy of the layer and merge them both.

18/ In the Layers Panel place the feathers layer below the subject layer then merge them.

Although this process may seem quite involved, this  is in fact a very quick and dirty way to remove a background from an image, although bear in mind the image will probably need working on afterwards.


Post a Comment

Home About Calender Contact Advertise
Copyright © 2014 SL-Inspiration | All Rights Reserved. Design By Blogger Templates