It is currently Fri Apr 19, 2024 7:37 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 15 posts ] 
Author Message
 Post subject: How do I remove the background from an image?
PostPosted: Sat Jul 05, 2008 1:54 pm  (#1) 
Offline
Retired Staff
User avatar

Joined: May 22, 2008
Posts: 6947
Location: Somewhere in GIMP
This is a frequently asked question about gimp. This works if your background is one color; it will not work on multiple-colored backgrounds.

Be sure your image is RGB mode: Image > Mode > RGB.

This is the method I use when the background is all one color and I want semi-transparent pixels (antialiased) around the image. Make sure your background color is white. If the picture background it is a color other than white I use the Color Picker and store the color as the foreground color. Do NOT add an alpha channel to the layer. If the layer name (usually named Background) is not bolded, right-click the layer and choose Remove Alpha Channel - the layer name will be bolded.

This is the original picture.
Image

Use the fuzzy select tool and click the background. If you notice there are small places not selected in the background try raising the Threshold, re-click the background and see if that gets those stray pixels. If not, select Quick Mask, zoom in and find those pixels and paint them with a white brush by clicking the switch tool on the color selector. When you are finished, close Quick Mask, and switch the colors so that the background color is white again.

This is a high zoom picture of the background in the picture. You can see the stray pixels that seem to gather in pictures. You don't want those.
Image

Make sure your background color is white and Delete. Those off-colored pixels are gone. That is because there is no alpha channel and gimp chooses the background color to replace what you delete.

Image

Click Select > Grow and make it 1 pixel. Your selection now has included one pixel of the actual image in the picture. If you have a background other than white that you saved, click the foreground color box and copy the color number.

Colors > Color to Alpha > Click the color bar and delete the color number in there and paste the number you copied from the foreground color. (Don't try to fudge and run the default white color in Color to Alpha first - you'll have a mess.) Click OK. Back to Color to Alpha, click the color bar one more time and change the color to white (ffffff). Run Color to alpha again and your background is now transparent. You can see in the zoomed in picture that the selection is inside the actual image. When you do this, the outer row of pixels becomes semi-transparent.
Image

Here is a screen shot of the apple after running Color to Alpha. You will notice that your layer name is no longer bolded. If you notice that the semitransparent pixels around the image are colored and you want them uncolored (if there is a black stroke around the image especially), while the image is still selected, Colors > Desaturate (I usually use the lightness selection but experiment). You can Undo (Ctrl + Z) and try a different selection in Desaturate. Those colored pixels will be come shades of gray.
Image

Here is a png image of the apple with a transparent background.
Image

Keep in mind, this is not the only method of removing a background. I use this one a lot and it works well for me.

_________________
Image
World War IV will be fought with sticks and stones. - Albert Einstein


Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: How do I remove the background from an image?
PostPosted: Thu Sep 02, 2010 11:22 am  (#2) 
Offline
Script Coder
User avatar

Joined: Jul 14, 2010
Posts: 697
In case anyone is interested, I have a script that implements this (more or less).

http://www.silent9.com/incoming/scripts/transbg.scm

It uses the upper left hand corner of the layer as the background colour to remove.

It shows up under Layers->Transparency.

-Rob A>

_________________
Image
Fantasy Cartography and Mapping by RobA


Last edited by RobA on Mon Apr 22, 2013 8:29 pm, edited 2 times in total.

Top
 Post subject: Re: How do I remove the background from an image?
PostPosted: Thu Sep 02, 2010 11:49 am  (#3) 
Offline
Retired Staff
User avatar

Joined: May 22, 2008
Posts: 6947
Location: Somewhere in GIMP
RobA, that is an awesome script.

I love that I can set the threshold, the amount of shrink and can make the holes transparent.

I made this quicky image and flattened it to try it out. I left the threshold 25, shrink = 1, and checked Make the Holes Transparent. All done in the click of the OK button.

Image

I also tried it with the original image posted in this tutorial. Perfect! :clap
Image

_________________
Image
World War IV will be fought with sticks and stones. - Albert Einstein


Top
 Post subject: Re: How do I remove the background from an image?
PostPosted: Thu Sep 02, 2010 5:54 pm  (#4) 
Offline
Retired Staff
User avatar

Joined: May 22, 2008
Posts: 6947
Location: Somewhere in GIMP
One more. Original image is here

I used shrink 2 in the script. After I ran the script I used the paths tool to select around the shadows and ran the selection through color to alpha with white.

Image

_________________
Image
World War IV will be fought with sticks and stones. - Albert Einstein


Top
 Post subject: Re: How do I remove the background from an image?
PostPosted: Fri Sep 03, 2010 6:14 am  (#5) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14709
Location: USA
Very nice!
Thanks for that script Rob.

_________________
Image
Edmund Burke nailed it when he said, "The only thing necessary for the triumph of evil is for good men to do nothing."


Top
 Post subject: Re: How do I remove the background from an image?
PostPosted: Sat Oct 01, 2011 3:25 am  (#6) 
Offline
GimpChat Member
User avatar

Joined: Sep 12, 2011
Posts: 377
Location: UK
That's a handy script to have. Thanks rob


Top
 Post subject: Re: How do I remove the background from an image?
PostPosted: Sat Oct 01, 2011 10:49 am  (#7) 
Offline
Global Moderator
User avatar

Joined: Oct 06, 2010
Posts: 4045
Rob: Can I, or Rod host your GIMP script collection on our website as an alternate download location? Or perhaps upload some at the Registry?

_________________
"In order to attain the impossible, one must attempt the absurd."
~ Miguel de Cervantes


Top
 Post subject: Re: How do I remove the background from an image?
PostPosted: Sat Oct 01, 2011 12:05 pm  (#8) 
Offline
GimpChat Member

Joined: Apr 12, 2010
Posts: 5870
Well RobA has a impressive collection of good scripts, most were a bit hidden in his side that now seems offline other sparse in replies to questions here on GC, GT on the registry and even at the carthographergilde..

For several if not all would be needed also summarize what request they fulfill and how, if not may be hard too guess
(as may be hard to guess some menu placement as for the gradients scripts...all placed in the most logical and functional but somehow harder to guess menu, the menu that appear only when right clicking on the gradient tool
And are all great scripts may be worth few note and screenshot to explain..)

_________________
My 3D Gallery on Deviantart http://photocomix2.deviantart.com/
Main gallery http://www.flickriver.com/photos/photocomix-mandala/
Mandala and simmetry http://www.flickriver.com/photos/photocomix_mandala/

Image

Mrs Wilbress


Top
 Post subject: Re: How do I remove the background from an image?
PostPosted: Sat Oct 01, 2011 2:35 pm  (#9) 
Offline
Script Coder
User avatar

Joined: Jul 14, 2010
Posts: 697
PhotoComix wrote:
Well RobA has a impressive collection of good scripts, most were a bit hidden in his side that now seems offline other sparse in replies to questions here on GC, GT on the registry and even at the carthographergilde..

For several if not all would be needed also summarize what request they fulfill and how, if not may be hard too guess
(as may be hard to guess some menu placement as for the gradients scripts...all placed in the most logical and functional but somehow harder to guess menu, the menu that appear only when right clicking on the gradient tool
And are all great scripts may be worth few note and screenshot to explain..)


My "big plan" was waiting on 2.8 and start updating them to use new features (particularly layer groups as most of my scripts use layers heavily) and then posting on my site, with example and such, much like:
http://www.silent9.com/blog/archives/14 ... ushes.html
http://www.silent9.com/blog/archives/16 ... Match.html
http://www.silent9.com/blog/archives/15 ... -Path.html
and
http://www.silent9.com/blog/archives/15 ... lugin.html

(The ones I actually have pages for.) Generally, I make them in response to a personal need or based on a specific request. Many are insanely specialized and have limited use, others are quite handy for most folks.

-Rob A>

_________________
Image
Fantasy Cartography and Mapping by RobA


Last edited by RobA on Mon Apr 22, 2013 8:33 pm, edited 1 time in total.

Top
 Post subject: Re: How do I remove the background from an image?
PostPosted: Sat Oct 01, 2011 3:26 pm  (#10) 
Offline
GimpChat Member

Joined: Apr 12, 2010
Posts: 5870
maybe i could have phrased better but mine was a positive comment

PS i still use very often Save and Export script, and was so clearly commented i could even add in my copy openraster format to jpg and png without no much trouble .

i would not be able to edit if was not written so clearly

_________________
My 3D Gallery on Deviantart http://photocomix2.deviantart.com/
Main gallery http://www.flickriver.com/photos/photocomix-mandala/
Mandala and simmetry http://www.flickriver.com/photos/photocomix_mandala/

Image

Mrs Wilbress


Top
 Post subject: Re: How do I remove the background from an image?
PostPosted: Tue Oct 11, 2011 10:16 am  (#11) 
Offline
GimpChat Member
User avatar

Joined: Jul 08, 2011
Posts: 285
I would love to download this script but I don't know how???? :(

_________________
Image

My Flickr
http://anaplus.deviantart.com/


Top
 Post subject: Re: How do I remove the background from an image?
PostPosted: Tue Oct 11, 2011 10:32 am  (#12) 
Offline
Retired Staff
User avatar

Joined: May 22, 2008
Posts: 6947
Location: Somewhere in GIMP
You can get the script here, too, Ana, and over on the right in the list, click Transparent Background and it will download. http://gimpscripts.com/2011/10/transparent-background/

_________________
Image
World War IV will be fought with sticks and stones. - Albert Einstein


Top
 Post subject: Re: How do I remove the background from an image?
PostPosted: Tue Oct 11, 2011 10:36 am  (#13) 
Offline
GimpChat Member
User avatar

Joined: Jul 08, 2011
Posts: 285
Oregonian wrote:
You can get the script here, too, Ana, and over on the right in the list, click Transparent Background and it will download. http://gimpscripts.com/2011/10/transparent-background/


Thanks ''O''.I made it.And I'm really impressed with this script.

_________________
Image

My Flickr
http://anaplus.deviantart.com/


Top
 Post subject: Re: How do I remove the background from an image?
PostPosted: Tue Oct 11, 2011 9:10 pm  (#14) 
Offline
GimpChat Member
User avatar

Joined: Apr 08, 2010
Posts: 5420
Location: Northwest Ohio
I love the gimp scripts site...it's so nice to just click to download to the scripts folder instead of copying, pasting, saving, etc. Great for us lazy people!


Top
 Post subject: Re: How do I remove the background from an image?
PostPosted: Sun Mar 03, 2013 7:09 am  (#15) 
Offline
GimpChat Member
User avatar

Joined: Jan 10, 2013
Posts: 863
Oregonian wrote:
You can get the script here, too, Ana, and over on the right in the list, click Transparent Background and it will download. http://gimpscripts.com/2011/10/transparent-background/


Thx Oregonian

For the tutorial!
Rob's link is dead, so also thanks for the link.

_________________
bbbbbbbbbbbImage
bbbbbbbbbbb Be patient, English is not my language.


Top
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) AI Remove image background(use rembg)

49

No new posts Attachment(s) Use of Fuzzy Select tool to remove white background from black text

2

No new posts Attachment(s) Remove Stain from Image

5

No new posts Attachment(s) Remove white background but keep white inner

6

No new posts How is the background removed from this image?

2



* Login  



Powered by phpBB3 © phpBB Group