Skip to main content

<Bitmask>

Category: Control tag

The Bitmask tag for pixel-wise image segmentation tasks is used in the area where you want to apply a mask or use a brush to draw a region on the image. It is the unlabeled counterpart of <BitmaskLabels>: use it when you have only one label to assign, or when you want to attach labels from a separate <Labels> tag pointed at the same image.

Bitmask operates on pixel level and outputs a Base64 encoded PNG data URL image with black pixels on transparent background.

Export data example: data-url:image/png;[base64-encoded-string]

Note: You need to set smoothing="false" on the Image tag to be able to work with individual pixels.

Use with the following data types: image.

Attributes​

AttributeTypeRequiredDefaultDescription
namestringyes—Name of the element
toNamestringyes—Name of the image to label
smarttrue,falsenotrueShow smart tool for interactive pre-annotations (takes effect when auto-annotation is on)
smartOnlytrue,falsenofalseOnly show smart tool for interactive pre-annotations
strokewidthstringno15Initial brush diameter, in image pixels. In practice the toolbar's own size control governs: the bitmask tool starts at 15 and is adjusted with the vertical size slider (1–50) or the [ / ] hotkeys (±5).

Behavior​

  • Adds two tools to the image toolbar: Bitmask (brush, hotkey B) and BitmaskErase (eraser, hotkey E), in the "segmentation" group alongside Brush / Eraser.
  • Each stroke set becomes one BitmaskRegion whose mask is kept as a PNG data URL; erasing paints transparency back in. Undo/redo tracks mask changes.
  • Because Bitmask carries no labels of its own, a region drawn with it is unlabeled unless a <Labels> tag pointed at the same image has a selected label when you draw — then that label is applied.

Result format​

{
"from_name": "mask",
"to_name": "image",
"type": "bitmask",
"original_width": 1920,
"original_height": 1080,
"image_rotation": 0,
"value": {
"imageDataURL": "data:image/png;base64,iVBORw0KGgo…"
}
}

Imported predictions / results are recognized as bitmask regions whenever value contains imageDataURL. When labels are applied through a <Labels> tag, the label result references the same region id.

Examples​

Basic image segmentation labeling configuration​

<View>
<Bitmask name="mask" toName="image" />
<Labels name="labels" toName="image">
<Label value="Person" />
<Label value="Animal" />
</Labels>
<Image name="image" value="$image" smoothing="false" />
</View>

Single-class mask, no labels​

<View>
<Bitmask name="foreground" toName="image" />
<Image name="image" value="$image" smoothing="false" />
</View>

Gotchas​

  • choice, maxUsages, and showInline belong to <BitmaskLabels> (a labels tag) and are not read by <Bitmask>.
  • Masks are PNG rasters: large images produce large data URLs in the result. Prefer <BitmaskLabels> / <Bitmask> over <BrushLabels> / <Brush> when you need exact pixels rather than stroke-based masks.
  • The Bitmask tool shares the B hotkey with the Brush tool; don't put <Bitmask> and <Brush> on the same image unless you're happy cycling tools from the toolbar.