How to edit instance segmentation masks

Instance segmentation masks are a collection of individual paint layers for an image that can overlap. This differs from semantic segmentation masks, which have a single paint layer. Thus, how you edit instance segmentation masks differs from how you edit semantic segmentation masks.

When you pull up a masks+image chart, there is a segmentation context menu at the lower left of the chart (figure below). It contains all the functionalities for editing a mask. They are, from left to right, paint, erase, erase all unselected layers when painting, delete layer, add layer, and select label. The function is active when the icon is green.

Edit an existing mask

To add paint on an existing mask, you can follow these steps:

  • select the mask (click it on the chart) that you want to edit

  • click the “paint” icon, if it is not active, in the segmentation context menu

  • select one of the paint tools (next to the arrow icon) at the upper right corner of the Charts panel

  • paint on the chart

How to select a mask underneath another one

If the mask you want to select is completely covered by another one, you can click the same spot multiple times to loop through all the masks that are under the pixel you clicked on.

To erase some paint from an existing mask, you just need to select the “erase” icon in the segmentation context menu. All other operations are the same as above.

Tips

You can press space to switch between the pan and paint mode while painting a mask, so you can easily go back and forth between painting the mask and panning the image.

Create and paint a new mask

You just need to start with clicking the “add layer” icon in the segmentation context menu and paint the newly added mask the same way as above. Note: you don’t need to select the newly added mask before painting, because it’s automatically selected right after it’s created.

When you paint a mask, the default behavior is that any pixels that belong to other masks will be erased while you are painting the currently selected mask. This ensures that a pixel can only belong to one mask. If you do not want other masks to be modified, you can click the “erase all unselected layers when painting” icon to turn it off.

Delete a mask

To delete a mask, select the mask and click the “delete layer” icon in the segmentation context menu. Alternatively, after selecting the mask, you can RightClick and then click Delete layer in the context menu or simply press Delete to delete the selected mask. You can also delete multiple masks at once by selecting them all together, which can be done by holding the Ctrl key while clicking the masks.