Mobile app version of vmapp.org
Login or Join
Angela777

: How to make a b&w mask identical with the image in photoshop? I've got a simple hair image and want to create a b&w mask for it. I've selected the black color via Select-->Color Range

@Angela777

Posted in: #AdobePhotoshop #Mask

I've got a simple hair image and want to create a b&w mask for it. I've selected the black color via Select-->Color Range and then inverted selection. Finally I've painted the selection with pure white color.


When I put the mask under the color image I noticed, that it's edges are slightly visible. I've tried to duplicate the image and desaturate/bright it to create a mask, but after layering it under the color image the result was the same.


How to make a mask, which'll be identical with an image (the mask's edges won't be visible)? It's important to me since I am making the 3d hair texture in 3d software and after applying transparency to it the final result looks really ugly.


P.s. Please go easy on me guys, since this is my first question here :).

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Angela777

--> Facebook Tweet Color Range">Reddit Digg LinkedIn -->

2 Comments

Sorted by latest first Latest Oldest Best

 

@Margaret771

Here the hair is synthetic. There's no noise, color contamination and radical irregular brightness & contrast variations. It should be far easier than a natural one.

Unfortunately all easy to use automatic (=do not draw it by yourself) masking tools in Photoshop still fail miserably. Long sharp corners and 1 pixel wide low contrast curves simply are not in their zone of comfort.

If the user has substantial underhood knowledge, he still can bypass the troubles and get usable results by using rare functions with surprising parameter combinations. That is not the way for us, the ordinaries. We need something easy. Here is one:


select your photo and copy it to the clipboard
paste it onto empty Inkscape artboard
goto Path > Trace bitmap
select mode = brightness cutoff and "smooth"
set a low treshold brightness, say 0,01. This is possible due the solid black background and very low noise. Play a little to find a good setting
on the Options tab deselect "smooth corners" see other options from the screenshot
press OK




Move the original aside. It can be exported as PNG if you want to insert it in Photoshop to a layer mask. For that


create a layer mask
open the PNG as another photo and copy it into the clipboard
open the layer mask by Alt+Click onto the mask icon in the layers panel
paste
see the result by clicking the photo icon in the layers panel


Here is a high zoom screenshot. There's adde a red underlay to test how accurate the mask is



The black areas are small and a 1 pixel shift brings the red visible. This gives a good reason to assume the mask acceptably good.

The mask in Inkscape is SVG vector drawing. It should be possible to have it as vector mask in Photoshop. I do not know that procedure, usability nor benefits well enough to show an unwavering example.

10% popularity Vote Up Vote Down


 

@Michele215

I have done some 3D renders and I know the frustration.

The theory behind it

Let us make a zoom on this circle and see what is happening. This is what you want. A red shape transparent on the borders. (If you put this image "A" on diferent background it will blend properly the rest are totally opaque.)
otake.com.mx/Foros/ImageAndMask-01.png
If we see the real image and the mask separately we will notice something. The transparent red pixels are actually red and we have a mask where we expect it to be.
otake.com.mx/Foros/ImageAndMask-02.png
But when we have a pre rendered image, with anti alias on, thoose pixels are no more red, but diferent grades of pink.
otake.com.mx/Foros/ImageAndMask-03.png
Most of the masking techniques rely on reducing the mask, so the transparency is "eating" more where you have not the modified color, so you do not see this halo.
otake.com.mx/Foros/ImageAndMask-04.png
A method of using your exact image as a mask

1) Open your image

2) Go to the channels panel and select the most contrasted one. In this case Red.

3) Duplicate it. Name it for example "MASK". Now select it and turn the eye on.

4) Image > Adjust > Levels (Ctrl+L) and pick the white droper on the correct area, the darkest hair fill. Press Ok.


Depening on the image you could need to move the slider a bit more to the left.


Now you have an alpha channel that uses the exact same antialiased the original image used. A beauty.
otake.com.mx/Foros/MaskFromAntiAliasedImage-08.png
5) You can load this channel Selection > Load Selection and choose "MASK" Channel.
otake.com.mx/Foros/MaskFromAntiAliasedImage-09.png
Let us work with your image

6) Invert the selection, we will work with the black area.

7) Now we need to expand this selection.


Selection > Modify > Expand > And use 2 pixels.


From this selection make a new layer (Copy Paste) Name it "Halo1" and you will have a layer like this.
otake.com.mx/Foros/MaskFromAntiAliasedImage-03.png
Note that we now have a slight brown halo of two pixels.

8) Duplicate this layer. Move this layer with the keyboard one pixel to the right and one down.

And move the other "Halo" Layer one pixel to the left and one up.

On this both layers use the blending mode "Lighter Color"

Remove any selection and flaten the layers.

You have now a slightly "fatter" image.
otake.com.mx/Foros/MaskFromAntiAliasedImage-04.png
Let us compare it versus the original (on the right):
otake.com.mx/Foros/MaskFromAntiAliasedImage-05.png
9) Now go back to your Alpha Cannel MASK where you saved the original selection.


Selection > Load Selection > And choose your alpha channel.


10) Copy + Paste and now you have a neat image with no halos.
otake.com.mx/Foros/MaskFromAntiAliasedImage-06.png
Note

There are still a thin dark part on the tips of the hairs. To remove them try to use the "halo" layers, instead of moving them 1 pixel, move them 2 or 3.

An automatic quicker method (in recent versions of photoshop)

But I have not compared it to the other result.


Using your selection "MASK" make a new layer
Menu > Layers > Halos > Remove Halo > and try 1 or two pixels.

10% popularity Vote Up Vote Down


--> Facebook Tweet Color Range">Reddit Digg LinkedIn -->

Back to top | Use Dark Theme