What Is A Mask In Digital Imaging

A grayscale gradient, an image and the gradient applied to the image as a mask are shown.
Masks us the grayscale values of pixels to determine transparency, not colour/.

Masks in image editing software are a way of protecting specific areas of your image, just as you would use masking tape when painting your house. A mask consists of a grayscale channel, called an alpha channel and is often displayed as a ruby overlay so the underlying image can be seen through the mask. The darkest areas of a mask are the areas most protected and the white areas are unprotected. Shades of gray represent areas of partial protection that corresponds with the level of gray.

Masks are employed in various ways depending on the software program, but the basic concept is the same. They all use the a grayscale value to apply varying levels of transparency to a layer or image or, in the case of black and white, to protect areas of an image. Transparency is indicated by a checkerboard pattern in image editing software; that's why you see the checkerboard pattern in this image.

In its most basic form a mask is nothing more than a a grayscale bitmap image. The pure white areas in the image represent the portions of your original image that will be 100% protected. The pure black portions of the image represent the areas of your original image that are completely masked out, or erased. The levels of gray in-between allow your image to be partially protected. If you have trouble keeping track of which color does what, just think of masking tape to help you remember... masking tape is usually white or light colored, so the white areas of your mask are the most protected.

Image editing software allows you to save your masks as grayscale images so they can be used over and over again.

In the above example, you can see how the grayscale colours in a gradient interact with the underlying image. The gradient runs from Black to White and when that image is used as a mask with the original image, the grayscale values ,which range from 0 to 255, in each pixel are used to determine opacity or transparency rather than color.

A mask does not have to be a separate image. Most software , such as Photoshop, allows you to paint a mask directly onto your image. It works the same way... painting with black while in mask mode erases the underlying layer of your image, and painting with white brings it back. Shades of gray allow you to paint in partial transparency. Using Black and White brushes is a very common technique when it comes to managing the edges of a mask.

When you're painting in mask mode, the mask is usually represented on the screen by a red overlay as shown in the above example from Adobe Lightroom. The ruby overlay lets you see the mask represented by a reddish tint and any areas not covered by the mask will not be affected by any edits applied. Some software allows you change the overlay tint color.

How is a mask different from a selection?

Other than the way each of them is represented on the screen, there's really not a lot of difference between a mask and a selection. 

A mask is represented in shades of gray, or with a ruby overlay, but a selection is most often represented with a dashed line marquee. When you're talking about a selection, it's important to remember that the selected area is the part of the image that is unprotected.

The areas outside of the selection are masked, or protected. So in a way, a selection is the exact inverse of a mask. Still, as shown in the above image, a selection can be saved as an alpha channel and used as a mask.

Another difference between selections and masks is the way they are created. A selection is made by using any of the selection tools offered in your software (rectangular, elliptical, magic wand, lasso). A mask is created using the painting tools (any of the available brushes or a custom brush).