JJMack's integration of Background Replacement Tutorials using a Mask

This Tutorial write up is wordy for the benefit of the novice and only Windows keys strokes are noted.

It also will not contain the final image. For this tutorial I used one of Phil's images. I wanted a good image with a white background and did not have one of my own. I used Phil's feedback form asking for permission to post the altered image here that I would add his copyright. Never received a reply. He must be busy with something like PMA. So if you want the see my results you have to do it yourself. A good exercise and it should take less than a hour. It took me longer to type this for I can not type or spell two of my handicaps. Proofing took even longer I'm trying.

Note: The Photoshop level setting shown in this tutorial are the exact setting I used for this image. They would not be the same for other images and other setting might produce better results for this image.

  1. Down load from Phil's Cannon 1Ds Gallery file 021128-1114-01-capt1.jpg full resolution and open in Photoshop from here click on the original Warning LARGE FILE 6MB.

  2. In layers pallet click the add new layer icon the one at the bottom next to the trash can. Double click on the name layer 1 and rename the layer to Healing Brush. Select tool healing brush checked use all layers and clean off dark round spots on background. If you can not see them view at 100%. Using the healing brush on a empty became available in Photoshop CS. If you do not have CS use the clone tool.
  3. In the layers pallet click on the add adjustment layer the icon before the add new layer icon and select Levels from the pop up menu. Adjust Levels while holding the Alt key pressed adjust the white triangle on right to the value is 232, then adjusted gray gamma to .87 to darken a bit. This makes the background ALL white. I held the ALT key during the adjustment so I could see where I was going over gamma you don't want to blow out too much of the model.

    Steps 2 and 3 are not needed but a really wanted a pure white background and this image was close and with these steps I now have a white background. Time to create a mask for the image.

  4. Click Channels Tab in the Layers/Channels/Path pallet. Then click on the red channel, then on the green channel, then on the blue channel. looking at the channels look for the one that has best contrast between the foreground and the background. In this case I think Blue does. Dupe the Blue channel by dragging the blue channel and dropping it on top of the add new layer icon. It is next to the trash can icon on the bottom of the channels pallet. Double click on the name Blue Copy and rename it to Mask.

    Now you work on the Mask to improve it. Note edges that are not real hard should be kept gray so the can later be tweak with Levels. I normally start with apply image screen. However multiply might be a better choice and when the background is not white you may first want to invert the Mask. Take the following steps as a example. That work for this particular image.

  5. Use Photoshop menu Image, Apply image "Source" 021128-1114-01-capt1.jpg "Layer" Background "Channel" Mask "Blending" Screen "Opacity" 100% check mask and invert at bottom click OK.
  6. Use Photoshop menu Image, Apply image "Source" 021128-1114-01-capt1.jpg "Layer" Background "Channel" Mask "Blending" Multiply "Opacity" 100% check mask and invert at bottom click OK.
  7. Ctrl-L Levels move sliders Black 75 gray gamma .80 White 225. The 225 selected because info pallet showed all background would have K of 0%. You find this by adjusting the white triangle slider a little and then moving the cursor over the background area while observing the info pallet.
  8. Select tool Lasso(L) ruff select the area inside of model. Press D key this sets default colors Foreground Black, Background White. Press X exchange colors press the Delete key fill selection with background color that is now set to black.
  9. Ctrl-D deselect or Photoshop menu Select, Deselect.
  10. Select tool Paintbrush and in tools option menu select a hard round brush set mode overlay a high% opacity and 100% Flow, If you have a Wacom Tablet use the brush tab in the docking well to pull down brush dynamics. Set brush dynamics, size to pen pressure and other dynamics, opacity to pen pressure and back in the tool option menu opacity % to 100.
  11. Press D key, sets default paint, Black foreground, White background.
  12. View at 100% or 200%(Alt-Ctrl-0)(Ctrl-+) paint over hard edges like the rear of the coat and front shoulder and paint the solid interiors all 100% black. Stay away from outer hair strands and fur fringe on coat leave these gray. I stayed away too much so there would be a problem area in fur fringe.

    The mask is now complete. Time for a replacement background. To start with I going to try a black one for its hard.

  13. In the channels pallet switch back to RGB mode click on the RGB channel.
  14. Click on the layers Tab in the Layers/Channels/Paths pallet.
  15. Click on the Add new layer icon in the layers pallet and double click on the new layer's name Layer 1 and rename it to "New Back". Fill the New Back layer with black I used the Paint bucket tool you could also use menu Edit>Fill or shift+F5. Because the layer "background layer" background is white set the New Back layer blending mode to multiply this trick is from Martin Evening's book "Adobe Photoshop for Photographers". If the "background layer" background is not solid white leave blending mode set to normal.

    Now you know why I wanted a white background.

  16. Use Photoshop menu Select click load selection, in load selection "Document" 021128-1114-01-capt1.jpg "Channel" Mask the one created from the blue copy and click on OK.
  17. In the layers pallet click the add layer mask Icon. It is the second icon on the bottom of the pallet circle in a square icon. This will add layer mask containing the selection (the mask) and this layer mask will be the current target. You can tell this because the icon next to the layer visibility eye icon is a the mask icon circle in a square not a paint brush. You can switch between the layer and the mask by clicking on their icons in the layer in the layers pallet. The model should now be seen and the mask should be pretty good.

    Next improve the Mask just try using some filters and adjustments don't apply any at first just see what affect they have on the image. With the Layer mask as the current target.
    Try Photoshop menu Filter Other maximize 1 pixel then higher.
    Try Photoshop menu Filter Blur Gaussian Blur 1 pixel then higher.
    Try Photoshop menu Image Adjustment Levels(Ctrl-L) play with the sliders.

  18. I went with just a (Ctrl-L)Levels adjustment black 11 gamma 1.3 White 255. You can improve the mask more if you have the time and energy by touching it up with black and white paint. I touched up the fringe on the coat a little with a few strokes of black paint in overlay mode. I could do better. The left ear could use a little work too but left it alone.

    At this point the job is done. The rest just go on to show some other things you can do.

  19. Once your satisfied click on channel tab and dupe New Back Mask and rename it Final Mask. You should now be able to use any background masked with the final mask.

  20. Finally I decided to change the New Back layer from black to something else. Switched the target from the layer mask to the layer itself by clicking on the layer icon in the New Back layer in the layers pallet. Then hit (Ctrl-A) select all and the hit the delete key which delete the black the layer is now transparent so you see the original image. Selected the Gradient tool which may be hidden under the paint bucket and selected the spectrum gradient from gradient picker pull down menu. If you do not see it you may have to load it use the Gradient picker fly out menu click the upper right icon triangle in a circle and click on load gradient. The ones that ship with Photoshop can be found in \Program File\Adobe\Photoshop\presets\gradients. Tool options radial gradient, mode normal, opacity 100%, dither, transparency. Move the cursor to between the models eye clicked and hold the left mouse button and dragged straight down to the bottom on the image and released the mouse button. There is now a colorful target behind the model, Next I gave it some texture used Photoshop Filter Distort Glass Frosted.

  21. For the fun of it I duped the background layer and moved it on top of the layer New Back. I renames the copy to Cut Out, used select load selection final masked and checked the invert box before clicking OK. Then clicked the add layer mask icon to add a layer mask to layer cutout and turned the visibility eye off. Also unlinked the mask in the New Back layer. I said for fun. Un-linking the mask in the New Back layer keeps it aligned with the background model and I can now move the new back layer position the spectrum gradient and scale it for better position. If I turn off the visibility of all the layers under the Cut Out layer and turn on the visibility of the cutout layer you see it looks like an extraction. The extraction is only as good as its mask the wispy hair ends that came through because of the multiply blend in the New Back Layer are gone. Because the Cut Out layer mask the inverted final mask is linked I can position the Cut Out layer and it will remain masked.

Had planned to include a scaled down image and a link to a full resolution with permission.

I'm considering upgrading to a Canon 1D Mark II system so have been reading quite a bit of the Canon 1D/1Ds forum lately. A while back there was a thread about background replacement. So I put my two cents in about Masking being the best way particularly if the original background was white. Alan Boyle responded white can still be hard if you have a lot of hair. Feel free to give this a shot.

Link to large Original
as you can see the image was small and the background hair soft. So I asked for a larger version Alan was obliging and posted a link to the original photo he placed on pbase for me. The above image is a link to his original aRGB image and here is Alan Boyle Home Page.

Am sure Alan though this image would be difficult to mask. The shallow depth of field placed some of the hair out of focus and most likely there is some motion blur. These are the only things that make masking this image at all hard.

First I cleaned up the image a little, converted it to sRGB,sharpened it and saved it. Here is the result this Web size image is also a link to the full size image.

Link to large sRGB Version

Next I masked it the and saved it. There is also harsh lighting on her chin and highlights have been blown away I made no attempt to touch this up. Next I dragged in a new background on top of the image and because the original background is white I changed the layers blending mode to multiply. Result is seen here before the layer mask is added you can see how well the Hair shows through. The image after that one shows the result of adding a layer with the mask I made and fine tuning the mask the result scaled down to Web size image. The Image is also a links to the full size images.

Link to large Original
Link to large Original

Same Layer Mask with Layer blending mode Normal see how much multiply gained

Link to large Original

If you un-link the Layer Mask from the new background you can position the new background with the move tool.

Link to large Original

Why most novices have a hard time of it.

They want to do a perfect job so they try too hard to create a perfect mask. You need a good mask when the background is not white. You want a less then a good mask when the background is white.

When you start to create the mask you have no Idea of how well it will work with the new background so you should not try to hard. Your basically blind during this step. The one rule of thumb you should keep in mind is the transition area between the fairground and background are the most critical. Don't mess around in there while your blind. Leave these area untouched.

Now when the original background is white you know you are going to recover lost detail by using blending mode multiply. Because if that you know you can make the mask smaller in this case to help not get a hallo around the foreground.

This image has a white background and I helped it along by using levels and set the white point using the white dropper on the background near the models hair. I duped the Red channel and started there. The first thing I do after that is do an Image Apply Image Mode Screen and check Mask. I do this to help shrink the mask a bit. I may darken up the transition area with a Second image Apply mode Multiply and check mask. Or I may use levels and move in both the black and white points. I then fill in the solid part of the foreground. This is your starting mask rename the red copy to MASK.

Next you place you new background on top and set the blending mode to multiply. The image below should show through and you should see no hallo around the foreground. At this time load you MASK as a selection and add a layer mask. Now you can see how well your mask is working. Most likely not all that well. The Mask needs to be adjusted but now your not blind and you can see how effective the Layer Mask is, Normally I start with levels and slide the middle triangle toward the left black end. This shrinks the mask some more. You can also try filters like Other Maximum 1 pixel. Sometimes a Gaussian blur will help.

From experience I normally can get buy with a level adjustment and a little painting with the brush set to mixing mode overlay painting with black and white on the mask. Below are my two mask for this image. You should see my layer mask which is the final mask is smaller and lighter in the transitional areas when compared to my original MASK. The Web sized images are links to the full size images.


Link to large sRGB Version

Layer Mask

Link to large sRGB Version