Sign up now! · Forgot password?
RSS/Atom feed identi.ca Twitter

Tutorial: Perfect masking using a highpass

Written by · Created on Sep 05, 2007, last updated over 3 years ago CC BY-NC License
Perfect masking using a highpass

Motivation

There are several methods to extract/mask objects or persons from the background. But sometimes you need perfect masking that includes for example the hair of a woman. The method i use for this is called highpass. We need to simulate this filter because there is no filter in GIMP that does this for us. The point of the techqnique is that you'll save lots of time for the difficult hair part, because when you do everything right the hair is extracted automatically.

Tutorial details

  1. 1

    Open any picture that contains a big shot of a person / celebrity / whatever. I use a picture of a well known celebrity.

  2. 2

    Duplicate the background layer 2 times, you should that layer 3 times then. On the top layer use Filter / Gaussian Blur: 18px. Set the layer to 50% transparency in the layers dialog.

    Then go to Colors / Invert. You should have something similar to my picture now.

  3. 3

    Click the right mousebutton on the layer in the layers dialog and choose “Merge down”.

    Colors / Desaturate (average). The go to Colors / Curves and apply a soft S-curve as seen on the image below.

  4. 4

    Then choose Brightness & Contrast from the same menu. This step can vary when you use a diferent picture. We’re aiming to get a good clearly vivisble contrast. Its important thyt you get nice contrast in the hairs area.

    We’re now done with the highpass filtering.

  5. 5

    Go to Colors / Invert.

  6. 6

    Now you need to take a brush and paint the body of the person / object with white. To make it easier to correct mistakes you should create an empty layer above the highpass-layer and paint on this layer, when done merge the layer down. You can move the background-layer above all layers and set the transparency to 20% or so to see what parts you have to paint.

    IMPORTANT
    You don’t have to paint the hair! Thats the point of this technique / tutorial. The hair should be already white, and everything behind the hair should be dark gray or black so you dont have to use time to get the hair extracted.

  7. 7

    When you have the person white you have to paint the background black. Start at the borders of the body. You can do this fast when you first use a smaller black brush to paint around the person (where the gradient from black to white is visible), and then using a very big brush to fill the rest of the background with black.

    If you use a sperate layer dont forget to merge it down at the end.

  8. 8

    At the end you should have an image containg almost only black an white. We use this as a layer mask now.

    Press CTRL+A (Selection / All), copy this using CTRL+C (Edit / Copy). Activate the background where the person is. Click right in the layers dialog, choose Add Alpha channel.

    Click right again and add a layer mask. Press CTRL+V (Edit / Paste) then and use the anchor-button in the layers dialog to get the copy onto the layer mask. You should the see the result immideatly. Make a white new layer behind all, then you can see the results even better!

    Good luck and have fun!

Comments

Post your own comments, questions or hints here. The author and other users will see your posting and can reply to it.

Of course, you can also ask in the chat.

Subscription management

Please log in to manage your subscriptions.

User rating

This topic (Perfect masking using a highpass) has been rated 5.0/5.0.

*

As a registered user, you can rate articles and comments, attach files to comments, subscribe to topics and you don't need to solve CAPTCHAs anymore.

*…optional

no1ze maschin3
12 months ago

after painting with white in step 6, can i not paint black using a layer mask?

Krysta Kaos
over 1 year ago

Yeah really cool

Shamim
over 1 year ago

I like the idea of this tutorial, it’s very creative and the result looks great

John
over 1 year ago

Thanks for this most instructive tutorial. It is to the point and leads you to the target (seamlessly, despite the fact that step 8 is a bit more tricky than it first appears).
Now, you want to do something with the end picture you get. It means that you've to save it in a format that the Gimp can further manipulate for an animation or what-have-you. I discovered to my dismay that what the Gimp saw was limited to the background -- the original -- or the top layer. Not the resulting picture. Couldn't find any other way than taking a screen snapshot to use it further on, which is silly.
So, how can you flatten or merge the layers so that you get the final picture on one single layer in jpeg or png format? Obviously, you could do it if I take a look at the 2 last pictures (right above) of your tutorial.

Anna Malena
over 1 year ago

thank you very much for publishing this tutorial! it's the best methof i've ever tried for extracting pictures with hair or other small details in them and my first attempt gave me a beautiful, near perfect result, so once again thank you :).

Erik
almost 2 years ago

I've been using channel mixer rather then curves, one question tho:

Any tips on how to mask blank objects? I'm doing alot of masking of lamps,details,furnitures etc. Photo's are taken inside a photo-tent with a few different background colors available. But whenever I have a picture of a blank object, such as silver etc, the blank surface takes up some of that background color - thus making it really hard to get a good contrast between object and background.

shoebutton member for over 2 years shoebutton 2 comments rated this topic with 5/5
almost 2 years ago

Thank you . I was working on a picture of a bee, and it was great for picking out all those little hairs.

anthony
almost 2 years ago

i dont think this works unless the picture is extremely high quality with perfect lighting

patdavid member for almost 3 years patdavid 1 comment
almost 3 years ago

@gnonstick
I have a tutorial specifically for layers if you are confused as to how to use them:
http://blog.patdavid.net/2011/05/getting-around-in-gimp-new-layer.html

It might help to get a handle on the process...

hth

gnonstick
almost 3 years ago

the tutorial may be an exelent method, however, right from section 2 it is impossible to begin to do this. how does a beginner know how to duplicate background without simple instructions. there are no instructions!
for e.g. "to do this you need to duplicate background, to duplicate background click (such and such...)"

so for me as a beginner i cant begin to understand a word of this. i did find in the "images" tab menu "duplicate" but it just gave me two more seperate windows with the sme image. but what the hell am i meant to do with this? ok that may not have been what you meant, but you do not describe HOW to duplicate background.

i think you forget that any one needing a tutorial is a beginner, or is learning the technique for the first time and most likely will not know what you know. so how can you expect section two to make any sense. and if section two does not make any sense, then it follows that none of the tutorial mkes an sense to me.
then you say black layer? what black layer?
gussian? i went to filter menu, but the gussian thing just gave me a small window with a blurred image!
therefore couldnt even begin section 3.

could you please make instructions more "systematic"?
it shouldnt be too dificult to treat the reader as an absolute beginner?

theBra!n™
about 3 years ago

I dont understand from 6 to 8 :(

Jess
over 3 years ago

It worked okay, but it left a small border around the image of the original (though it is a uniform border) I can see this being okay for things where the context of the image isnt important, you just need a cutout for say, a flyer, but not if you wish to move the image into another background and it look natural or splicing things together

Intermediate rated this topic with 5/5
almost 4 years ago

As said above, it works best with neutral backgounds. However, I used it for a picture of my mom in a kayak with the city surrounding her (all I wanted to do was gaussian blur around her so she's the focus point) and with a little bit of extra technique added (actually, quite a bit of extra) I came out with a close to perfect mask. So I think if you know what you're sorta doing with the gimp, you can come out with an acceptable result.
HOWEVER, if my goal was to cut her out and put her on a white background, it would not have turned out as well. So it all depends on the picture and what you're using it for. I will definitely try to remember this teqnique, and use it in the future.
A big thanks to the author!

Garmahis
almost 4 years ago

This tutorial is featured on 70 creative Gimp tutorials
http://garmahis.com/tutorials/gimp-tutorials/

mahvin
over 4 years ago

@ 37. clinton:

Exactly! You're just setting up the original layer to be "mask-ready", and then pasting the black/white layer into that mask ready "place-holder" (for the lack of a better term in describing it).

In laymen terms, just look at adding a mask to a layer as "opening the box flaps" so you can paste the actual mask "into" the theoretical box. Once you paste that mask into the original layer, you don't really need the black/white layer anymore because as Clinton explained @ #36, by pasting it into the original layer with alpha channel and mask layer, you have essentially hard-wired your transparency ranges into the image.

clinton
over 4 years ago

Yeah, and what you "initialize" the layer to just means "how do you want to start to draw your mask" and it doesn't matter what you pick because you already have a mask you're going to paste in anyway.

clinton
over 4 years ago

You are doing two things: adding an alpha channel to your background layer (the one with the person you are cutting out) and then you are adding the black and white mask you just drew. The alpha channel is the fourth "colour" in RGBA which represents how transparent a pixel is. With the mask you just made, you are actually drawing the alpha channel you want, where black is completely transparent, and white solid. So step 8 is telling you to copy your mask to the clipboard (select all and copy), add an alpha channel to your RGB background layer by right-clicking on it in the layer-selector and saying "add alpha channel". Finally, add a mask for your background layer (poke around, don't have Gimp installed right now!) and paste your mask into it.

Danny
over 4 years ago

I'm new to GIMP(v2.6.7) and was able to follow along up to Step 8. I am completely lost at step 8 when directed to add a layer mask. At that point I can't follow along. Screenshot: http://s135501958.onlinehome.us/Step8.jpg

Toàn Pham
over 4 years ago

Mahvin, Thanks - Bernhard's tutorial gives a good background on this, but an update and additional details so that beginner can follow would be soo nice. Yep, the busy background would actually not be a problem, since we can just hand clean most of it out. The real work is the edges around the main image with hair and all. Thanks & look forward to it!

mahvin
over 4 years ago

@ Toàn Pham:

I'll work on a newer version of this tutorial sometime this weekend and post it on my blog at mahvin.com. I don't want to hijack Bernhard's tutorial, but it does need to be updated since GIMP versions and scripts have improved since September 2007.

One other reminder: this technique only works with certain types of pictures, that don't have a busy background.

Rada
over 4 years ago

Everything went just fine up to step 8, but then the instructions become very unclear. I could not go further, but I am a beginner with GIMP.

Toàn Pham
over 4 years ago

Donato & Mahvin, I really hopefor your guys's help with a bit more explanation as I am a beginner at this (and need to get some pictures cut our with lots of edges and hair for a brochure). I think the Edge-Detect > Sobel is good, but what next. Please help with the details. I am really needing a little more help!
Thanks!

mahvin
over 4 years ago

You can get the same effects for steps 1 thru 5, in 3 quick steps using 2.6.6.

1. Run Filters - Enhance - Adaptive Contrast

2. Desaturate - average

3. Colors - Invert

I would then add a new layer, use the Free Select tool (lasso) to select the inside edge of Jolie's body on the new layer and fill it with white. Then use Select - Grow to expand the selection just outside the outline, invert it, and fill the background with black. These two steps would save you a lot of time

flamingmarsh
over 4 years ago

it works for me and im a beginner!

cath
almost 5 years ago

..the step 6 i dont get it..

Donato
about 5 years ago

I've done something similar in easier way using Filter -> Edge-detect -> Sobel (GIMP 2.6.5).

Toàn
about 5 years ago

Could the author or someone rewrite steps 7 & 8 with some more details breakdown for GIMP 2.65, because the options are now a little different.
I have had some success with this, but still not smooth. Thank you.

Sera
about 5 years ago

I've used it on some semi-complex backgrounds with no problems and the hair was super long and tight curls in motion. Worked great.

Wado
over 5 years ago

Good trick give me more

Dan
over 5 years ago

You guys should use part of the review of GIMP 2.6.1 over at inatux.com http://www.inatux.com/reviews/GIMP2.6.1review like as a reference, they also have a very good video that might be good for your "Videos" category.

Alby
over 5 years ago

Nice.
do you know if there is a nice tutorial in italian language to help me in removing people from complicated background?
Thks
Alberto

hrod
over 5 years ago

I've tried the various extraction techniques,
They all work with pretty much the same efficency.
I have even used "select reigons by color". My thing,
(and i am relatively new to all this) is not so much
"perfect extraction"( and how do u define this?),but
how long does it take?, and what must be done after
the mask is complete.(touch up). so far all methods
have proven to need touch up.

Sarah
over 5 years ago

can someone help??? i get to the first 2 steps and when i do the color invert it goes greenish blue?

Poganka member for almost 6 years Poganka 3 comments
almost 6 years ago

Great tutorial, thank you! To achieve
desirable results I had to play with contrast of the BW layer. Actually, ended with maximum. Then I used (gaussian) Blur. Working with four layers I could see the result right away. Thanks again!

doubled
almost 6 years ago

something like this is VERY case sensitive. I think you really need to have a good understanding for the entire program toget good results. Yes, some images are easy to extract, yes some tutorials work for some other images, but you need to have multiple methods.

I have one method I use for every image but it uses a combination of different masking techniques and explaining it would be near impossible, theres just to many steps.

What you can look into is Highpass, selective color, desaturation, the pen tool with vector masks/clipping masks, threshold, brightness/contrast, curves, laso tool and color channels.

for EVERY image i try to extract I use a combination of all of the mentioned above. Some used more then others in different cases, but all of them will be used. Thats how you get a perfect extraction. different parts of the image call for different things.

read up on all of them and try to understand them. it will help yoy extract images and understand photoshop a lot more.

devvv member for over 7 years devvv 1390 comments
almost 6 years ago

yes, i know. this is another efficient way to do this - and a more common way. you should however know all ways to do such things to combine them. not all photos are the same

Alex Railean
almost 6 years ago

I found it, there you go: http://www.gimpguru.org/Tutorials/SimulatedDOF/

This is how you obtain the mask.

And this is how you use it to remove the background: http://www.gimpguru.org/Tutorials/ReplaceBackground/

Alex Railean
almost 6 years ago

Interesting, but it is not the most efficient way; there is a similar tutorial that explains how to do this by splitting the image to its individual channels and then ehnancing the contrast on the layer where the shapes are distinct (usually one channel has better contrast). By the time you do that, nothing but the object itself is seen - so you get your mask "for free", with no manual actions.

Unfortunately I can't find that turorial anymore.

Greg
almost 6 years ago

This is a very helpful method for certain types of backgrounds. Some people are complaining, but as a professional designer, I can tell everyone that you HAVE to know several different ways to do this. Hair is one of the more complex things to extract from a background. Great tut, another weapon for the arsenal.

mulder
about 6 years ago

nice, don't know thats so simply to cut out the background from an complex image

Rich
over 6 years ago

This is my second time tring this. and the first time it looked really bad, but I must say if you follow step by step it does really work very well. Thanks

ei!
over 6 years ago

the tutorial is awesome, but not applicable to all photos... specially those with complicated backgrounds... but its helpful anyway!!>.<

meh
over 6 years ago

Only useful where the background is neutral enough to select with the magic wand.

Litchi
over 6 years ago

I think this tutorial is great ! I used it to extract a girl with a lot of hair falling before the background and the result is very satifying. It might work only on simple backgrounds, but it is nevertheless a useful manipulation. Thanks !

devvv member for over 7 years devvv 1390 comments
over 6 years ago

of course this works best with backgrounds like mine. but nevertheless, this is a common technique in image manipulation, you should know it, its really helpful in some specific situations. of course you may combine some techniques together to get best results.

however, this is not the typical tuitorial for most of you guys. you're better with manual doing with the bezier/paths-tool.

M.rSnow
over 6 years ago

Extremely awfull results whit strong backgrounds. extremely meany better ways of doing it. The tool u get when u press [I] is better.(I dont know the name)

SasQ
over 6 years ago

I have some questions about this technique:
1. Which one is better: more blur or less?
2. What if there are light background fragments left on hair? [on thin hair lines, especially on their ends].
3. What to do if the background contains hard edges? This technique amplifies them too.

Gimp Fan
over 6 years ago

Awsome! It worked great following your instructions step by step! Thanks!

Anonymous
over 6 years ago

Awful, simply awful results. Only good for an image with an incredibly neutral background.

anon
over 6 years ago

rubbish. left me with a total mess. do you honestly thing painting over something will give you good results?

Kushal Abrol
over 6 years ago

One of the most useful tutorials ever seen

tyewonk member for over 6 years tyewonk 1 comment
over 6 years ago

I couldn't finish because Add Alpha Channel was grayed out. My image is set to RGB.