Mask
A mechanism that controls visibility of image regions using greyscale values. Layer masks enable non-destructive editing by hiding rather than deleting pixels.
A mask controls the visibility of specific image regions using greyscale values: white areas are fully visible, black areas are fully hidden, and grey areas are semi-transparent. Because the original pixel data remains intact, masks are used in non-destructive editing workflows.
Key mask types in image editing:
- Layer Mask: A greyscale image attached to a layer. Paint white to reveal, black to conceal
- Clipping Mask: Uses the opaque area of a lower layer as the shape boundary for upper layers. One use is displaying images within text shapes
- Vector Mask: Defined by a path shape. Edges remain crisp at any scale since the boundary is mathematically defined
- Quick Mask: A mode for visually editing selections as masks, displaying non-selected areas with a red overlay
In web development, CSS mask-image applies masks to HTML elements. Gradient masks create fade-out effects, while SVG paths enable complex shape clipping:
mask-image: linear-gradient(to bottom, black, transparent)- Fades content downwardmask-image: url(shape.svg)- Clips to an SVG shape
In image processing code, masks are implemented as binary or greyscale arrays of the same dimensions as the source image. OpenCV applies masks via bitwise operations: cv2.bitwise_and(img, img, mask=mask).