Proper subject extraction, background removal, and background painting |
|
Dec 29, 2011, 20:56
(This post was last modified: Mar 4, 2013 01:11 by ofnuts.)
Post: #1
|
|||
|
|||
|
Proper subject extraction, background removal, and background painting
Beginners very often wonder why a faint border remains around sharp items such as letter or logos when they remove or bucket-fill the background around them.
The explanation: when a border isn't a straight vertical or horizontal, it will look jagged /pixellated, if done with plain pixels because pixels on a computer display are big enough to be visible. To avoid this "anti-aliasing" is used: instead of having only two colors for the pixels (subject color or background color), pixels along the edge of the subject are made partially colored or partially transparent: When you wand-select the background or bucket-fill, you specify a threshold that says how close are the colors you want to select. If the threshold is low, you don't select the anti-aliasing pixels, so you leave a faint border uncolored or uncut: But if you use a high threshold, you apply the color (or select) bluntly to the anti-aliasing pixels so they disappear and you are left with a jagged border: So, obviously, these anti-aliased pixels are the most precious part of your picture and you should never, ever, use any processing that destroys them. And to do so, there is only one solution: draw the shape on a transparent layer. This way, the anti-aliasing is done using partially transparent pixels... The next post will show why this is is important. ![]() |
|||
|
Dec 29, 2011, 21:01
(This post was last modified: Dec 29, 2011 21:02 by ofnuts.)
Post: #2
|
|||
|
|||
|
RE: Proper subject extraction and background painting
Now, if you want the background color to blend smoothly, you just have to paint *under* these pixels, and their partial transparency will do the rest... And since where the pixels are fully opaque the underlying layer won't show, the best way to paint the background around the subject is to add a layer below and fill it with the color:
With some combination of colors this may create a slight visually dark outline (it is the case above). This can be alleviated by using the "Levels" tool on the alpha channel of the layer on top, to alter the transparency of the anti-aliased pixels. By making them a bit more transparent (drag the middle cursor to the left), the dark outline disappears before the jagged look sets in: ![]() |
|||
|
Dec 29, 2011, 21:07
(This post was last modified: May 12, 2013 16:50 by ofnuts.)
Post: #3
|
|||
|
|||
|
RE: Proper subject extraction and background painting
Now, the $1000 question is: you have this nice logo already on a colored background, how do you get it on a transparent layer with the proper anti-aliasing?
In other words, how do you replace the border pixels with mixed colors by partially transparent pixels? Well, Gimp has a magical tool for this, which is called "Color to alpha" (the "alpha channel" is the channel, that, next to Red/Green/Blue ones, controls the opacity of a pixel). Here is how you can use it: First, you use the Magic Wand to select the background, with a low threshold (you will notice that only the palest anti-aliasing pixels get included in the selection): Then you grow the selection by one pixel. This makes it include all the anti-aliasing pixels(*): Then, you apply "Colors/Color to alpha", using the background color as the reference color (in the picture below I put a white layer under the transparent layer to better show the recovered transparency on the border pixels): And you can repaint that underlying background, to show how well this works: Now, all this was done using several layers, but sometimes it's more convenient to work on just one layer. And Gimp also allows this, using two specific paint modes, "Color erase" and "Behind" that are complementary. - The "Color erase" mode does exactly the same thing as Color-to-alpha, it replaces the painted color by transparency. Bucket-filling the selection in "Color erase" mode give identical results to Color-to-alpha. Like Color to alpha is is best used with a selection that covers the anti-aliasing pixels but protects the rest. In the image below the yellow brush strokes magically produce semi-transparent blue pixels: - The "Behind" mode produces the same visual result as painting on a layer below the active layer. The paint is fully applied, where the active layer is transparent, partially applied where it is partially transparent, and no painting occurs where the layer is fully opaque. In this mode you can just paint around your subject and the painting will magically blend into the opaque parts: (*) The smart reader will ask: why do we grow the selection instead of selecting everything? It's because Color-to-alpha faces an ambiguity. There are several ways to produce a given color, depending on the opacity: a light gray on white can be either:
![]() |
|||
|
Dec 29, 2011, 21:49
Post: #4
|
|||
|
|||
|
RE: Proper subject extraction and background painting
One last thing... you can of course wonder how you can repaint the subject and keep these precious anti-aliasing pixels partially transparent... it happens that there is something for this called "alpha lock". When this box is checked (see red circle below), the alpha channel of the whole layer remains unaffected by paint operations. This mean that if you want to apply one single color you can bucket-fill the whole subject layer, the background will remain transparent, and the anti-aliasing pixels will get the new color while remaining partially transparent:
![]() |
|||
|
Jan 5, 2012, 04:34
Post: #5
|
|||
|
|||
|
RE: Proper subject extraction and background painting
Awesome! It worked and it looks so good.
Basically you just: 1. Use the wand and select the background 2. Grow by 1 pixel 3. Color>Color to Alpha Mine was on a transparent layer, and I chose the color white, and I am assuming since the original background color was white, this is why it cleared up the smudges? Well excellent work Ofnuts just what we needed! |
|||
|
Oct 5, 2012, 20:22
Post: #6
|
|||
|
|||
|
RE: Proper subject extraction, background removal, and background painting
This is not proper extraction, this is stupid workarounds cause fill bucket doesnt do its job and its laughable in 2012 year that nbody took care of it yet.Now people are forced to use lahyers to do simple stuff which takes one click in photoshop, thats just pathetic.
|
|||
|
« Next Oldest | Next Newest »
|
| Possibly Related Threads... | |||||
| Thread: | Author | Replies: | Views: | Last Post | |
| transparent background | musicstuff | 3 | 809 |
Jan 28, 2013 15:22 Last Post: Majik Imaje |
|
| Need to Change Background Colour | srinirex | 1 | 405 |
Dec 21, 2012 08:52 Last Post: ofnuts |
|
| Exporting Elliptical/Round Selections WITHOUT Transparent Background Boxes | dsvendse | 0 | 244 |
Dec 19, 2012 07:19 Last Post: dsvendse |
|
| Painting hair with Gimp | Jibrielle | 0 | 528 |
Nov 9, 2012 14:40 Last Post: Jibrielle |
|
| Painting Tutorial - 2D/3D Integration | LJFHutch | 0 | 545 |
Feb 16, 2012 10:42 Last Post: LJFHutch |
|

Search
Member List
Help
GIMP Tutorials


![[Image: 2Tvo0.png]](http://i.imgur.com/2Tvo0.png)



![[Image: banana.gif]](http://clampingworld.yuku.com/domain/bypass/images/banana.gif)