Lasso tool

The lasso (or "free form selection") is an editing tool available, with minor variations, in most digital image editing softwares and some specific strategy games. It is often accessed from the standard main menu (in Photoshop, Paint Tool SAI, and GIMP, as common examples), by clicking the icon of a dotted line shaped like a rope lasso, from which the common name arises.

Standard operation
The lasso tool operates on the active layer of an image, and is used by clicking and dragging to trace the edges of a selection. Most software supports multiple closed contours, which can be selected by crossing over the edge path multiple times. It is also typically not necessary to close the shape: releasing the mouse button triggers the software to close any open loop(s) automatically. The area enclosed by the cursor path will remain selected and open to various transform operators (shift, scale, cut, copy, and paste, for example) until elsewhere in the image is clicked. At this point, the lassoed selection will merge with the layer it was selected from.

Characteristics
In contrast to other image selection algorithms such as intelligent scissors, magic wand, or grabcut, lassoing places no requirements on the image, as the user is free to create any closed path.

Technical description
From an image processing standpoint, the lasso is fundamentally a masking tool. The edges of the mask are defined by user input: the path of the cursor while the button is held down. A temporary new active layer is created which contains the logical AND of the masking layer and the active image layer. Meanwhile, the original active layer is masked (logical AND) with the inverse of the lasso selection. This creates the impression that the tool has sliced out a piece of the original image for selective transforms and edits. Most operations available for a full image can now be applied to the temporary active layer.

When the layers are merged, pixels in the temporary active layer will replace the pixels in the active layer with which they coincide. "Empty" pixels are handled in one of two ways depending on whether or not the imaging software supports alpha compositing. They may take on the value of a default "background" color, or they may continue to be defined as transparent with an alpha channel value of zero.