Lusus

Remove The Background From An Image Using G'MIC in Gimp


In this blog we've previously covered a number of methods to remove the background from an image. The difference with this method is, whilst it works very well with images with a plain background, it can also be used to remove a complicated background scene, leaving just the foreground subject - which is what we'll be doing here.

For reference here's the other background removal methods already described in this blog, all of which are good to know:
All of the above methods have their pros and cons, and this is also true when using G'MIC. For instance, once a complex background has been removed, the image may need more editing and tidying up. Also, if the subject has messy detailed hair some of this detail will almost certainly be lost in the editing process.

If you prefer, there's a video version of this tutorial on our YouTube channel.

The G'MIC Plugin

G'MIC is an invaluable plugin for Gimp and has an incredible number of options for manipulating images. To install the plugin go to the G'MIC download page and click on the download link for Gimp. Once downloaded click on the executable and the rest of the installation will take care of itself. The next time Gimp is opened G'MIC will be installed under the Filters menu.

Remove The Background From An Image Using G'MIC

To remove the background from an image using G'MIC follow these simple steps.

The images here can be clicked to view full size.


1/ Open the image in Gimp, then select Filters > G'MIC.


2/ The above window will appear. From the list select Contours, highlighted in red.


3/ From the drop down list select Extract Foreground [Interactive]


4/ Settings for Extract Foreground will appear to the right of the window. Add a little feathering, highlighted in red, so the extracted foreground doesn't have jagged edges. A low number (here 0.04 is used) is all thats needed.

When you're ready hit the Apply button, lower right.


5/ The above window will open with the image loaded into it. This is the window we'll be using.


6/ To select the area of the image to be kept left click inside its outline. Green dots will mark where you've clicked. These dots do not need to be tightly clustered or too close to the edge of the foreground subject.


7/ To select the area to be removed right click to add red dots outside of the foregrounds' outline. Again, the dots don't need to be closely spaced or too near the edge of the subject.


8/ When you're ready hit the Spacebar on the keyboard to preview the background removal. As you can see it works well, but needs some adjustments.


9/ Both the red and green dots can be dragged to new positions. Left click and drag for green dots, and right click and drag for the red ones.

More dots can be added if they're needed. Their position is not ordered, so just place new dots where they're needed.

If you accidentally left click and create a green dot where you wanted a red one, just right click on it to turn it red. Visa versa for red dots where you wanted green.

If you add a dot by mistake, hit the backspace tab on the keyboard to remove it.


10/ As you can see it can take a little trial and error to get all of the dots in the right places. There's no undo function with this process, but you can continue to edit to get what you want. Just hit the spacebar each time you want to preview the editing.


11/ To zoom in to an area use the mouse wheel.


12/ When you've finished editing the image hit enter on the keyboard.


13/ Now hit OK bottom right of the G'MIC window.


14/ We're now back into the regular Gimp image window. To the right you can see G'MIC separated the foreground and background into different layers.


15/ Here the background layer has been deleted and a plain white layer added so the contour of the foreground can clearly be seen.

Some of the outline is still quite rough, and whilst it could be tweaked more using G'MIC, since the background has pretty much gone, removing the remnants will be straightforward. For this image I just needed to use the Eraser.


16/ This is the image after being cleaned up.


17/ Here I added a random background to show how the cleaned up foreground can be used.

Further Resources 

Whilst G'MIC isn't the only way to digitally remove an image background it is probably as good as you'd expect for a free option. Here are a few alternatives which it can more than compete with.

Remove Image background is a website that allows users to upload an image, and with the click of a button remove the background. Whilst it states its free, this is only true when images of a certain size are used. If larger images are uploaded the background will be removed but the final image will be resized.

If you want larger image sizes the website offers a subscription service, as well as a pay as you go service.

Cutout 8 is downloadable software that does a very similar job to G'MIC, although it offers more options. It comes in with a price tag of $99.00, so have fun with that. There is a 7 day trial version if you'd like to try it out.

Ashampoo offers the earlier Cutout 7 version of the above software at a reduced price of  $21.00, so this may be an alternative worth considering. Although the website states its on offer, this seems to be a permanent rather than a time sensitive arrangement.

Thats all there is to removing the background from an image using G'MIC in Gimp. Whilst it may seem a long process its actually quite quick and easy, although it may take a little practise. Like all background removal methods its not perfect, but this is the best way for removing detailed backgrounds, and as good as any of the above alternatives.