Jump to content

How to select dark hair on dark background


Recommended Posts

Most info on selecting hair is done on easy high contrasting background of just a few colours, unfortunately this situation is rare in real world backgrounds, unless you have the ocean or sky as a background.

As someone wrote this is the Holy Grail of graphic apps, so any suggestions how using AP?

 

 

 

Link to comment
Share on other sites

2 hours ago, Affinity Rat said:

Most info on selecting hair is done on easy high contrasting background of just a few colours

For good reason😁. Without constrast there is no differentiation between hair and pixels. You could probably mask out around the hair and use appropriate brushes to restore hairs outline and texture. The holy grail remains to be discovered😉

IPad Pro 10.5/512GB   lpadOS 15.3 Apple Pencil (1st gen), Affinity Photo 1.10.5 Affinity Design 1.10.5

Official Online iPad Help documents (multi-lingual) here: https://affinity.help/

PDF Help files available here:

Affinity Photo 1.9.2-help.pdf 

Affinity Designer Help File 1.9.7.pdf

Link to comment
Share on other sites

5 hours ago, Affinity Rat said:

Most info on selecting hair is done on easy high contrasting background of just a few colours, unfortunately this situation is rare in real world backgrounds, unless you have the ocean or sky as a background.

As someone wrote this is the Holy Grail of graphic apps, so any suggestions how using AP?

 

 

 

The basic answer is that it is an impossible mission for almost any app.

  • You can get fast results with AI/ML based apps or online services (what Affinity doesn’t offer currently).
  • You could use multiple methods like channel based selections, pre-processing the image (copy) to boost contrast and saturation and use this helper layer for selections
  • repaint hair instead of trying to mask 
  • Use saturation or hue based selection methods 

In case you have an image with similar hue/saturation/lightness of hair and background it is actually practically impossible to get an exact mask or selection. It is not limited to dark hair, can happen with grey or white hair. Use the other methods.

Often the background color spills over to the hair.

you can find zillions of tutorial videos on YouTube, this topic has been discussed thousand times in the forum.

 

Link to comment
Share on other sites

To release very fine details like hair from backgrounds is probably one of the most challenging things in image editing. How to do that depends on some preconditions like f.e. the contrast between the hair and the background and even the complexity of the background. Also the resolution of the image is important because if the single hairs are not much thicker than the pixels of the image, their colors will be a mix of the color of the hair and the background, so that it looks like a color blending. In many cases it is the better solution to erase the thin hairs and to restore them by painting. You can use thin brushes for this or prefabricated brushes with hairlocks and strands (that you can find on the web). You can take the colors you need for this directly from the hair, with the color picker.

To release objects from backgrounds, I usually select objects roughly first (usually with the Selection Brush Tool), then refine it as much as possible automatically, apply a mask and then refine it manually by using a brush that fits to my needs. To add single hairs, I use a thin brush with slightly reduced opacity, flow and hardness. This will of course work much better if you have a graphic tablet. In that case you can also use dynamics to let the brush get a little more and less thicker and more and less opaque by varying the pen pressure.

It will take some practice, good eyes and diligence. And you should not exaggerate. But I'm afraid, a one-click-solution for this problem doesn't exist.

One additional hint: always judge the result by using the zoom factor 100% (1:1). Otherwise you could fiddle until the final day, without need.

Link to comment
Share on other sites

To add another complication: the mask alone is only one half of the story. 
Having your perfectly masked person, the next (similar impossible) challenge is to remove the color cast of the source scene.

Again, most will chose the simple method and just apply a gradient map, or other methods to fully replace the colors.

 

 

Link to comment
Share on other sites

1 minute ago, NotMyFault said:

To add another complication: the mask alone is only one half of the story. 
Having your perfectly masked person, the next (similar impossible) challenge is to remove the color cast of the source scene.

Again, most will chose the simple method and just apply a gradient map, or other methods to fully replace the colors.

 

 

Yes, and there is one very important thing too, that many people that want to create collages don't think of: if you want it to look authentic, you have to consider the lighting perspective. It will always look somehow weird if the light on the inserted object comes from a different side than the light on the background.

Link to comment
Share on other sites

Too summarize the general challenges of selecting/masking objects and use them in compositions with different background:

  • selecting / masking
  • remove color casts (restore „natural“ colors object, remove color spill from lightning and background reflections)
  • remove shadows / lightness artifacts
  • ensure geometric composition fits (single / dual plane projection, angle / POV, and size of object)
  • tonal blend to composition (black pint, white pint, saturation, add color cast of composition)
  • create scene-compatible lightning and shadows (highlights / shadows)

 

Link to comment
Share on other sites

I agree with iconoclast, to accomplish this task takes, an understanding of the problem, ie resolution, complexity of background, colour contrast, lighting et al, and an understanding of the limitations of the software  (I’m not there yet) to create contrast necessary to make a  selection, but also not to be underestimated, artistic license to create.

When I first started this thread I was attempting to use the red colour channel, curves and levels, with limited success.

 

 

 

 

 

P

 

Link to comment
Share on other sites

Yeah definitely difficult to separate, you’re probably going to have to use a combination of techniques like everyone else was suggesting.

is this close to what you’re looking for out of curiosity? (Hard to make it look neat the way strands of hair are reacting to the wind)

 

image.png

Link to comment
Share on other sites

3 hours ago, Affinity Rat said:

Does working with 16 bit colour help?, I presume so but difference very subtle.

Depends as always. It helps to avoid banding when color grading. If using select sampled color, 16 bit seems to provide better results.

These are nuances, sometimes very helpful, sometimes irrelevant.

Link to comment
Share on other sites

11 hours ago, Affinity Rat said:

Can see at the bottom, I tried to refine result but not very successful.

It is almost impossible by laws of physics.


A single hair is mostly about 1-2 px wide, and it is almost never pixel aligned. So one hair of 1.2 px real world width will cover 2px. 
now you can only select the area of whole pixels. Affinity (like every other app) will use transparency to select these 2 pixels (width), one with very low and one with higher transparency (or both with about 40% if it is just in the center of both).


So the result is by laws of physics blurry, and colors of hair and background are mixed and cannot be separated (my masking).

Today we have “retina displays” with very high DPI of 250-350, this helps that normal observers won’t notice such details.

But you as photo editor will notice during the process when pixel peeping at 400% zoom.

You can somewhat extend the masking resolution to sub-pixel detail by using pen and curves and stroke profiles (in Designer). But this is of no practical use in most cases.

To summarize:

There are unavoidable limits to masking bitmap images.

You may try to oversample images (resample to 4x resolution), this will allow finer masking if hair will be 3-5 pixels wide.

It does not solve the color contamination.

 

Another issue: the image you uploaded shows strong jpeg compression artifacts (blockiness), this makes it even more difficult as some artifacts are looking similar to a hair, especially when increasing the contrast.

 

Link to comment
Share on other sites

Here a little fun exercise. The files contains one artificial blue hair on red background.

How simple could it be to select this hair perfectly?


on the right side, marked with P for pixel, please try to make a perfect selection of this hair. Save it as mask.

Then try to compare the mask with the alpha channel of the hair (in the lower section). 

I bet almost nobody is able to create the exact same alpha mask by selection tools in this totally simplified case.

Real world hair is much more complex. similar colors, out of focus, 100.000 hairs etc.

 

To compare two masks, convert them to greyscale layers, and align them atop of each other. Blend mode difference on top layer will show any differences.

9D1B2647-B7AC-4EAA-B901-5168E81CD546.png

masking testfile.afphoto

Link to comment
Share on other sites

I selected the hair from the upper right P layer created a mask, copied it converted to gray scale and moved to superimposed it over the cresent layer. Then changed the blend mode to difference. 
 

I dont know how to interpret the result, there was nothing displayed.

 

Link to comment
Share on other sites

Please find the simplified updated file below.

The exercise:

  • select the blue hair from red right upper corner
  • copy it and move it to green right lower corner

Try different selection methods (brush, magic wand, select sampled color, select hue range>blue, refine selection, using the crescent shape as vector mask, paint selection by brush, use color channels as mask, …) and compare them visually to the reference on the left.

You will see that it is next to impossible (only using selections) to perfectly blend one easy hair into a different scene, even in this unrealistic simple case where hair and background colors are totally different.

Refine selection will always introduce color spill. You need a lot of practice to tackle the unwanted side effects.

Using blend modes, or refine selection with “new layer with mask” will help to remove color cast.

When you have mastered this simple case, you may start to tackle more complex cases.

 

CD628115-D569-4077-8FE9-32BA2737600B.png

mask excercise.afphoto

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...

Important Information

Please note there is currently a delay in replying to some post. See pinned thread in the Questions forum. These are the Terms of Use you will be asked to agree to if you join the forum. | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.