# Segmentation

The Segmentation labeling tool allows you to segment images and create complex polygons with holes, with support for merging and subtracting polygons from one another.

{% hint style="info" %}
The Segmentation tool is supported across the Image, Video, and DICOM labeling editors.
{% endhint %}

![](https://3895963154-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTcOUG6rfWxqGM0N4db2P%2Fuploads%2FmHngleS1iN2J0EPQeval%2Fimage.png?alt=media\&token=69d9fca4-328a-4195-851e-41f1c31534a5)

## How to add a Segmentation tool to your project <a href="#how-to-add-a-bounding-box-tool-to-your-project" id="how-to-add-a-bounding-box-tool-to-your-project"></a>

From the project’s *Settings* tab, enter the *Label Set* section.

Click on *Add Category*. From the list that appears, click on *Segmentation*.

A new row will appear named *Segmentation*. Click on it to expand it.

![](https://3895963154-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTcOUG6rfWxqGM0N4db2P%2Fuploads%2FgDh324XoiDCQ5gUNk4z3%2FScreen%20Shot%202022-05-10%20at%2015.32.01.png?alt=media\&token=9d7a382b-5bcc-462e-9129-f4fe55145c46)

Give your segmentation tool a title and description.

Enable the *Required* toggle if you want to force labelers to create a segmentation for each asset. When the toggle is disabled, labelers will be able to save and move to the next asset without creating the segmentation.

If you would like to ask labelers further questions, for example, if you want to show a further *radio* after drawing the segmentation, click on *Add Classification* and add a further question. [More on nested questions here](https://docs.imerit.net/labeling/labeling-tools/tools/nested-classifications).

## Using the Segmentation Tool <a href="#how-to-draw-a-bounding-box" id="how-to-draw-a-bounding-box"></a>

Click on a segmentation tool from the *tools* section on the left of the screen.

### Manually

Click on the image where you’d like the segmentation to start. Click again somewhere else to create a new point, and so on:

<figure><img src="https://3895963154-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTcOUG6rfWxqGM0N4db2P%2Fuploads%2FaNI6IMep27MnaA1GwZLx%2Fseg-rough.gif?alt=media&#x26;token=1a73658c-8f9a-4712-99c6-259eff519f8d" alt="" width="426"><figcaption></figcaption></figure>

To create a fine-grained segmentation, keep the left mouse button (LMB) pressed to draw your segmentation:

<figure><img src="https://3895963154-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTcOUG6rfWxqGM0N4db2P%2Fuploads%2Fgwv4sRsZqX6MeBI6vMeO%2Fseg-fine.gif?alt=media&#x26;token=1237ead8-d82f-4c8c-8eaf-1e882cdec365" alt="" width="426"><figcaption></figcaption></figure>

When you are done with your segmentation, press N to close and finalize it, or click on the initial point as shown in the video above.

### With AI Assistance

Follow the instructions on the page for [Auto Suggestion](https://docs.imerit.net/labeling/labeling-ai-assistance/auto-suggestion).

### Cutting Out From / Creating a Hole in a Segmentation

Click on a segmentation on the image, then press on the "scissors" icon that appears. This will switch to "delete" mode. In delete mode, you can create segmentations the contents of which will be removed from any segmentation present on the image at the moment:

<figure><img src="https://3895963154-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTcOUG6rfWxqGM0N4db2P%2Fuploads%2Fq2jThoIDn1yp5ZXGnoNu%2Feraser.gif?alt=media&#x26;token=f63eacd0-ac4c-4201-a75c-21ee9245f057" alt=""><figcaption></figcaption></figure>

### Merging Segmentations

Select two segmentations belonging to the same class by shift-clicking them. The "merge" button will become active. Clicking it will merge the two segmentations. If they overlap, then they will then behave as one single segmentation, which you are able to adjust:

<figure><img src="https://3895963154-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTcOUG6rfWxqGM0N4db2P%2Fuploads%2FwB6txLBpHng0egQ76PPy%2Fmerge.gif?alt=media&#x26;token=b18f4df2-6d51-4637-94f7-9807c6cdde32" alt=""><figcaption></figcaption></figure>

You can also merge segmentations not overlapping. In that case, while they will not behave as one segmentation, they will be semantically grouped together in one instance, and in the export they'll be shown as a single 'object':

<figure><img src="https://3895963154-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTcOUG6rfWxqGM0N4db2P%2Fuploads%2FFaf30O2yvmQZlUL4MmsV%2Fmerge-separate.gif?alt=media&#x26;token=4390ec88-c035-4e7f-9bb8-b8eceed65a98" alt=""><figcaption></figcaption></figure>

### Subtracting Segmentations <a href="#differences-between-bounding-box-and-polygon" id="differences-between-bounding-box-and-polygon"></a>

By default, you can draw a segmentation over another, and they will overlap without subtracting one another.

If you have overlapping segmentations, Hub allows you make it so that one "cuts" into the other, such that the segmentation found below is cut (subtracted) by the one above, having no overlap in the end.

To do so, select two segmentations, by shift-clicking on them directly, or by shift-clicking on their list item in the *Objects* panel. The first segmentation you choose will be the one that will have no data removed. The segmentation chosen second will have part of it subtracted. Then, click on *Subtract*. You can see it in action here:

<figure><img src="https://3895963154-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTcOUG6rfWxqGM0N4db2P%2Fuploads%2FxbO7QLDvjCufH8NGuk4z%2Fsubtraction.gif?alt=media&#x26;token=623d5fd7-5331-4774-967f-66b5a0f4516c" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
If you can't click on a segmentation because it is obstructed by another one on top, you can:

* Click on its row in the *Objects* list instead, or
* Hide the object overlapping it by clicking on the ![](https://3895963154-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTcOUG6rfWxqGM0N4db2P%2Fuploads%2FQhWr4ByZLjJZbQwkYaJD%2Fimage.png?alt=media\&token=f0184f17-f0e3-49f4-b855-6e2ae2018edc) icon in its row, then select the object, then unhide the overlapping object by clicking on its eye once more.
  {% endhint %}

### Nudging Segmentations

You can apply small changes to your segmentations by 'nudging' them.

To nudge a segmentation, click on the segmentation on the asset, then pick the type of nudge tool you'd like to use:

<figure><img src="https://3895963154-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTcOUG6rfWxqGM0N4db2P%2Fuploads%2FpPtNXM38R2taD7JASVBn%2Fimage.png?alt=media&#x26;token=37614f9a-7379-448c-8474-790817bd751d" alt=""><figcaption></figcaption></figure>

Nudge Erase will allow you to reduce the size of your segmentation while applying small changes. Nudge Draw will add area to your segmentation.

Once you have picked your nudging tool of choice by clicking on either the "plus" or the "minus", click and drag around the segmentation's edge to refine the edge of your segmentation:

<figure><img src="https://3895963154-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTcOUG6rfWxqGM0N4db2P%2Fuploads%2FMigrJNC8X9FHNI77rhtV%2Fnudge-tool-complete.gif?alt=media&#x26;token=0d47299e-ee67-4737-a62d-9817bd58eebc" alt=""><figcaption></figcaption></figure>

### Adding to an existing segmentation

The *Auto-Merge* feature allows you to extend an existing segmentation instance.

To activate it, click on an existing segmentation, then click on the "Auto-merge" icon. Draw where you would like to extend the segmentation, then press N.

{% embed url="<https://angohub-docs-assets.s3.eu-central-1.amazonaws.com/3.17/auto-merge.gif>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.imerit.net/labeling/labeling-tools/tools/segmentation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
