gimpusers.com logo
German version English version

Not logged in

Sign up! | Lost password?

Latest discussion

  1. gimp-user | today 03:10 AM
    Quick compiling question
  2. gimp-user | yesterday 08:23 PM
    Installing gegl for gimp-2.7
  3. gimp-developer | yesterday 06:57 PM
    GIMP distributing sRGB profiles: license issues?
  4. gimp-user | yesterday 04:41 PM
    Enlarge Canvas: Is there a way to do it by dragging? Could/Should there be?
  5. gimp-developer | yesterday 12:23 PM
    [PATCH] OpenRaster: optimize PNG saving

External news

Poll

Would you like to be able to use your Google/Yahoo/MSN (OpenID) login on gimpusers, too?

Definately! I would enjoy the possibility to use my OpenID on different websites!

I don't have a special need for OpenID but I think it could be useful

Doesn't matter to me

Never, OpenID is a pain regarding privacy and personal data protection!

No. (please post a comment)

See results

Stats

gimpusers.com RSS feed

RSS feed Retweet this!

05 Sep 2007 08:00 AM, by devvv (Bernhard Stockmann)

Perfect masking using a highpass

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.

This article has been written using GIMP 2.4.rc2. It's divided into 8 steps and takes about 30 min to complete for an average user. 136665 times read so far. Category: Techniques, required skill: 3 of 5

38 comments have been posted so far.

Available in other languages:

  1. 1
    Open any picture that contains a big shot of a person / celebrity / whatever. I use a picture of a well known celebrity.
    Screenshot of step 1
    Click to enlarge
  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.
    Screenshot of step 2
    Click to enlarge
  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.
    Screenshot of step 3
    Click to enlarge
  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.
    Screenshot of step 4
    Click to enlarge
  5. 5
    Go to Colors / Invert.
    Screenshot of step 5
    Click to enlarge
  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.
    Screenshot of step 6
    Click to enlarge
  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.
    Screenshot of step 7
    Click to enlarge
  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!
    Screenshot of step 8
    Click to enlarge

This article is licensed under the following license: Attribution-Noncommercial 3.0 Austria

Links (pingbacks)

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.

Comments are chronologically arranged.

  1. http://www.gimpusers.com/tutorials/highpass-masking.html Sat 15 Sep 2007 09:45:01 PM CEST tyewonk, 15 Sep 2007 09:45 PM

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

  2. http://www.gimpusers.com/tutorials/highpass-masking.html Wed 19 Sep 2007 10:00:47 AM CEST Kushal Abrol, 19 Sep 2007 10:00 AM

    One of the most useful tutorials ever seen

  3. http://www.gimpusers.com/tutorials/highpass-masking.html Sun 23 Sep 2007 11:30:21 AM CEST anon, 23 Sep 2007 11:30 AM

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

  4. http://www.gimpusers.com/tutorials/highpass-masking.html Tue 25 Sep 2007 03:46:52 PM CEST Anonymous, 25 Sep 2007 03:46 PM

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

  5. http://www.gimpusers.com/tutorials/highpass-masking.html Fri 28 Sep 2007 04:04:43 AM CEST Gimp Fan, 28 Sep 2007 04:04 AM

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

  6. http://www.gimpusers.com/tutorials/highpass-masking.html Mon 15 Oct 2007 01:49:43 PM CEST SasQ, 15 Oct 2007 01:49 PM

    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.

  7. http://www.gimpusers.com/tutorials/highpass-masking.html Thu 18 Oct 2007 06:51:40 PM CEST M.rSnow, 18 Oct 2007 06:51 PM

    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)

  8. http://www.gimpusers.com/tutorials/highpass-masking.html Thu 25 Oct 2007 10:38:02 AM CEST devvv, 25 Oct 2007 10:38 AM

    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.

  9. http://www.gimpusers.com/tutorials/highpass-masking.html Sat 10 Nov 2007 02:46:27 PM CET Litchi, 10 Nov 2007 02:46 PM

    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 !

  10. http://www.gimpusers.com/tutorials/highpass-masking.html Thu 15 Nov 2007 03:58:25 PM CET meh, 15 Nov 2007 03:58 PM

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

  11. http://www.gimpusers.com/tutorials/highpass-masking.html Mon 03 Dec 2007 07:25:37 AM CET ei!, 03 Dec 2007 07:25 AM

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

  12. http://www.gimpusers.com/tutorials/highpass-masking.html Tue 18 Dec 2007 05:41:32 AM CET Rich, 18 Dec 2007 05:41 AM

    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

  13. http://www.gimpusers.com/tutorials/highpass-masking.html Thu 28 Feb 2008 05:55:50 PM CET mulder, 28 Feb 2008 05:55 PM

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

  14. http://www.gimpusers.com/tutorials/highpass-masking.html Sat 24 May 2008 02:38:46 AM CEST Greg, 24 May 2008 02:38 AM

    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.

  15. http://www.gimpusers.com/tutorials/highpass-masking.html Mon 26 May 2008 04:49:33 PM CEST Alex Railean, 26 May 2008 04:49 PM

    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.

  16. http://www.gimpusers.com/tutorials/highpass-masking.html Mon 26 May 2008 04:55:29 PM CEST Alex Railean, 26 May 2008 04:55 PM

    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/

  17. http://www.gimpusers.com/tutorials/highpass-masking.html Mon 26 May 2008 05:03:17 PM CEST devvv, 26 May 2008 05:03 PM

    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

  18. http://www.gimpusers.com/tutorials/highpass-masking.html Thu 10 Jul 2008 09:34:27 PM CEST doubled, 10 Jul 2008 09:34 PM

    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.

  19. http://www.gimpusers.com/tutorials/highpass-masking.html Thu 24 Jul 2008 07:25:02 AM CEST Poganka, 24 Jul 2008 07:25 AM

    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!

  20. http://www.gimpusers.com/tutorials/highpass-masking.html Wed 06 Aug 2008 04:10:46 AM CEST Sarah, 06 Aug 2008 04:10 AM

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

  21. http://www.gimpusers.com/tutorials/highpass-masking.html Tue 07 Oct 2008 01:39:10 AM CEST hrod, 07 Oct 2008 01:39 AM

    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.

  22. http://www.gimpusers.com/tutorials/highpass-masking.html Fri 17 Oct 2008 05:50:48 PM CEST Alby, 17 Oct 2008 05:50 PM

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

  23. http://www.gimpusers.com/tutorials/highpass-masking.html Wed 29 Oct 2008 10:28:42 AM CET Dan, 29 Oct 2008 10:28 AM

    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.

  24. http://www.gimpusers.com/tutorials/highpass-masking.html Wed 29 Oct 2008 01:52:31 PM CET Wado, 29 Oct 2008 01:52 PM

    Good trick give me more

  25. http://www.gimpusers.com/tutorials/highpass-masking.html Sun 25 Jan 2009 06:08:49 PM CET Sera, 25 Jan 2009 06:08 PM

    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.

  26. http://www.gimpusers.com/tutorials/highpass-masking.html Wed 18 Feb 2009 04:46:44 PM CET Toàn, 18 Feb 2009 04:46 PM

    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.

  27. http://www.gimpusers.com/tutorials/highpass-masking.html Thu 02 Apr 2009 10:27:39 AM CEST Donato, 02 Apr 2009 10:27 AM

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

  28. http://www.gimpusers.com/tutorials/highpass-masking.html Mon 29 Jun 2009 06:22:16 AM CEST cath, 29 Jun 2009 06:22 AM

    ..the step 6 i dont get it..

  29. http://www.gimpusers.com/tutorials/highpass-masking.html Tue 28 Jul 2009 05:23:41 PM CEST flamingmarsh, 28 Jul 2009 05:23 PM

    it works for me and im a beginner!

  30. http://www.gimpusers.com/tutorials/highpass-masking.html Mon 17 Aug 2009 11:20:25 AM CEST mahvin, 17 Aug 2009 11:20 AM

    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

  31. http://www.gimpusers.com/tutorials/highpass-masking.html Fri 21 Aug 2009 10:16:35 PM CEST Toàn Pham, 21 Aug 2009 10:16 PM

    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!

  32. http://www.gimpusers.com/tutorials/highpass-masking.html Sat 22 Aug 2009 09:44:54 PM CEST Rada, 22 Aug 2009 09:44 PM

    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.

  33. http://www.gimpusers.com/tutorials/highpass-masking.html Sun 23 Aug 2009 12:04:48 PM CEST mahvin, 23 Aug 2009 12:04 PM

    @ 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.

  34. http://www.gimpusers.com/tutorials/highpass-masking.html Mon 24 Aug 2009 05:21:09 PM CEST Toàn Pham, 24 Aug 2009 05:21 PM

    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!

  35. http://www.gimpusers.com/tutorials/highpass-masking.html Thu 22 Oct 2009 02:40:00 AM CEST Danny, 22 Oct 2009 02:40 AM

    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

  36. http://www.gimpusers.com/tutorials/highpass-masking.html Mon 07 Dec 2009 03:30:38 AM CET clinton, 07 Dec 2009 03:30 AM

    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.

  37. http://www.gimpusers.com/tutorials/highpass-masking.html Mon 07 Dec 2009 03:33:08 AM CET clinton, 07 Dec 2009 03:33 AM

    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.

  38. http://www.gimpusers.com/tutorials/highpass-masking.html Mon 07 Dec 2009 03:45:52 AM CET mahvin, 07 Dec 2009 03:45 AM

    @ 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.

Registered users can log in (top right of the page) to use their profile name to post comments, request email notification on new comments and attach images (e.g. their versions of the effect) to their postings.

Are you human?

Adobe® Photoshop® is a registered trademark of Adobe Systems, Inc. Linux is a trademark of Linus Torvalds. Ubuntu and Canonical are registered trademarks of Canonical Ltd. | Clock times are shown as CET / CEST | Imprint / Privacy policy | powered by bitfire it services