Color Masks in Gimp

Hello,
I would like to mask this lion on the photo, but I don’t know how I get enough contrast to select them:

[Dropbox - File Deleted]

I took the image and inverted and set the mode to “Wert(HSV)”. Then I get this image below:

For me it seems to bee good for masking, because there is much color contrast, but what are the next steps to get a beautiful black and white image with high contrast between lion and background?

Best regards

Martin

I would use the magnetic lasso tool to select the lion.

This is a tough problem that many of us have. Basically it’s a hair-masking problem (to help your search terms).

You are wanting to find a way to select something with a high amount of contrast specifically along the fine hairs of the lion’s mane. Have you tried other color decompositions to see if something else might suit what you want? RGB? HSV? I would try them and investigate the resulting layers to see if there’s one that has a good starting point of (higher) contrast between the mane and backround (maybe a green-channel?).

Unfortunately there’s no easy, one-click solution for this. It’s a game of pushing/pulling levels, curves and painting on a mask manually as needed. :frowning:

1 Like

I agree that this is on the difficult and time consuming side. At a glance, the brush behind the lion has a lot of stringy detail as well. I am poor at masking but what I would do is make multiple good enough masks and then integrate the best of those into one final mask. A mask to rule them all :wink:.

Using RawTherapee, you can get the following image without any masks in just a few minutes. Is it what you were looking for?
_MG_8538-2.jpg.out.pp3 (12.1 KB)
_MG_8538-2

2 Likes

You could use Gmic’s hue overlay masks:
https://discuss.pixls.us/t/hue-overlay-masks-my-first-filter/5000

Here I used the red mask (remember to set it to layer mode “normal” to see it):
_MG_8538_red

Quickly applied the levels tool in Gimp (could have done better using curves):
_MG_8538_red_levels

This should work quite well for selecting the hair, if that is what you wanted.

Here’s the red channel of the image plus the red mask in overly mode, plus some curves adjustment:
Lion#
Cheers

3 Likes

Maybe a bit off topic here, but if you use GIMP 2.9.x, you can try foreground extraction tool. Especially Levin-Matting algorithm is very powerful and you can achieve excellent results but be aware - it is extremely slow!

6 Likes

Wow that looks great. Thank you with the hint to change the algorithm.

At the moment Gimp crashes every time I try to change something in my actual configuration:
https://bugzilla.gnome.org/show_bug.cgi?id=789967

@s7habo Nice masking! I tried the foreground extraction tool before but because of my slow computer I gave up on it. Now the lion is awfully lonely :crying_cat_face:.

1 Like

There’s a little fringe, but that’s just me. I always am OCD with perfectionism. Unfortunately, that’s not going away.

@Reptorian I noticed that too and also how the selection is fuzzier than say @McCap’s method. The difference is that I don’t let this stuff get to me. What I would say is that knowing different ways of doing something can be advantageous, since one method might work for one image but not so well for another.

Curious: how would you normally tackle this problem given your perfectionism? By hand?

I tackle the fringe issue by experimenting with filters by starting to find the values of alpha is decent to work with on the start, and I manipulate that base image with long series of painting and usage of filter brush, and nondestructive filters. may or may not apply this to several different masked or on separate layersI gotten beautiful results by doing it by hand, but it is just really painful. I just often click the x if the efforts takes too long.

Is there a trick to that tool?
I tried it yesterday and it didn’t select much more than what I had selected?

Using the latest gimp AppImage from 2017-08-07 and the latest McGimp release on os x 10.11, using the Foreground Extraction tool, I can’t change the “Engine” combo box because it is grayed out. @patdavid @Carmelo_DrRaw @partha – any ideas?

@s7habo how on earth did you do that, could you record a video? I tried in 2.9.6, and like @paperdigits wrote I cannot select the engine, it’s grayed-out, and using whatever engine is active the result is and always has been garbage.

Yes, this is sometimes the problem with blurred or noisy parts of the image. The trick is first, to separate the foreground from the background as precisely as possible using brushes before applying the algorithm.
If the first result is not satisfactory, you can make further corrections with the brush by switching between foreground and background selection option of the brush.

What I don’t like about implementation in GIMP is that after the initial implementation of the algorithm after each additional stroke of the brush, the calculation is starting to run again! In this way, this already very slow process is unnecessarily stretched even longer.

In some cases helps “Feather Selection” option in brush menu.

If the foreground selection is done and there are still artifacts, I copy the selection to the new layer and make manual corrections with the help of eraser tool with low hardness and opacity switching between “erase” and “un-erase” mode of the tool.

I’m using Gimp from ppa:otto-kesselgulasch/gimp-edge and ATM I have GIMP 2.9.7.

Machine_selector

Strange, but until now, I’ve always had this option! I’ll make a video later and put it here.

1 Like

It is grayed out for me as well, I’m on @partha’s version (2.9.5 I think)

1 Like

You need to build gegl with libumfpack so that gegl:matting-levin gets build.

Edit: On Debian you need libsuitesparse-dev for that.

2 Likes

@Morgan_Hardwood Here’s the video:

Please note: I have scaled the original image for the faster calculation speed of the engine for Video and shortened the waiting times of the calculation. Original video length was about 6 min.

9 Likes

I’ll try to implement this in the appimage, and make a new package.

Thanks for the hint!

2 Likes