How GIMP Mask to Selection Converts Grayscale Opacity
In GIMP, converting a layer mask into a selection is a 1:1 data transfer between two identical grayscale channels, rather than a binary "on-or-off" decision. A layer mask defines the visibility of a layer using 8-bit grayscale values, and GIMP stores active selections using that exact same 8-bit architecture. When you invoke "Mask to Selection," GIMP reads the numeric brightness value of each mask pixel and maps it directly to the selection channel, producing feathered, semi-transparent selection weights that govern the exact intensity of future edits.
The Grayscale Architecture of Selections
While users typically visualize selections via the moving dotted line—known as "marching ants"—GIMP internally stores selections as a dedicated grayscale image channel called the Selection Mask. This channel shares the exact canvas dimensions and bit-depth of your image (typically an 8-bit integer channel with values ranging from 0 to 255).
Because a layer mask is also an 8-bit grayscale channel, the "Mask to Selection" function performs a direct, pixel-by-pixel copy of tone:
- Pure Black (Value 0): Becomes 0% selected. Any subsequent edit, fill, or filter ignores this pixel entirely.
- Pure White (Value 255): Becomes 100% selected. Edits affect this pixel at full strength.
- Mid-Grays (Values 1 through 254): Become proportionally selected. For instance, a neutral gray pixel with a value of 128 becomes roughly 50.2% selected (\(128 / 255\)).
The 50% Threshold and the Marching Ants
A common point of confusion is the marching ants boundary. GIMP cannot draw partial lines to represent partial selections; it can only draw a distinct vector outline.
To resolve this, GIMP places the marching ants threshold strictly at the 50% opacity boundary (pixel value 128). Pixels with a mask density value between 1 and 127 are still part of the active selection, but they sit outside the dotted border. Pixels with values between 128 and 255 sit inside the border. Even though the boundary appears sharp, the underlying selection retains all smooth gradients and partial opacities.
How Downstream Operations Use Selection Opacity
Once the mask values are transferred to the selection channel, GIMP uses the selection values as a mathematical multiplier for any subsequent action:
\[\text{Final Pixel Effect} = \text{Tool Effect} \times \left( \frac{\text{Selection Value}}{255} \right)\]
If you paint with an opaque red brush over an area derived from a 25% gray mask (value ~64), GIMP applies only 25% of that red paint’s opacity to the target layer. Similarly, pressing the "Delete" key on a partially selected region lowers the target layer's alpha channel proportionally, rather than cutting a hard-edged hole.
Through this direct channel-to-channel mapping, GIMP avoids hard thresholding, ensuring that soft brushes, gradients, and antialiased edges preserved in your layer mask translate precisely into the selection.