> ## Documentation Index
> Fetch the complete documentation index at: https://landinglens.docs.landing.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Segmentation

export const vp = 'Visual Prompting';

export const smartLabel = 'Smart Labeling';

export const productLL = 'LandingLens';

export const mi = 'Mobile Inference';

export const llsf = 'LandingLens on Snowflake';

export const companyName = 'LandingAI';

*This article applies to these versions of LandingLens:*

<table>
  <thead>
    <tr>
      <th>LandingLens</th>
      <th>LandingLens on Snowflake</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td><span class="check-icon">✓</span></td>
      <td><span class="check-icon">✓</span> (see exceptions below)</td>
    </tr>
  </tbody>
</table>

**Segmentation** is used to identify objects with great precision. This is done by using a "brush" or {smartLabel} to mark the exact location of an object you want your model to detect. This object type is commonly used for identifying irregular shapes.

Let’s say you want to identify cracks in cement. You could use Object Detection; however, bounding boxes would include too much background (or space that you do not want to include in your label). During model training, the model will look at every labeled pixel. If you include extra, unimportant pixels, the model might think these pixels are also important. Instead, use Segmentation so that you can precisely label the relevant areas. Compare the labeling options in the following images:

<img src="https://mintcdn.com/landinglens/lfi7C6xislw6Nqbm/images/bounding-box-seg.png?fit=max&auto=format&n=lfi7C6xislw6Nqbm&q=85&s=7e90537e990adbc9df6c120edab7281e" alt="Bounding Boxes for Segmentation" width="335" height="328" data-path="images/bounding-box-seg.png" />

<img src="https://mintcdn.com/landinglens/gSDZ622m6AYezIvW/images/Segmentation.png?fit=max&auto=format&n=gSDZ622m6AYezIvW&q=85&s=2b0c86303fa6dbd655e137b74c461b03" alt="Segmentation" width="325" height="326" data-path="images/Segmentation.png" />

## Labeling Tools for Segmentation

Segmentation offers the following tools to label objects. You can mix and match tools when labeling.

* [Smart Labeling](#label-an-object-with-smart-labeling): Click an area to auto-detect objects. {smartLabel} is not available in {llsf}.
* [Polygons](#label-with-polygons): Create a shape to fill the object you want to detect. You can also use this tool to "erase" labeled regions.
* [Brushes](#label-with-brushes): "Paint" over the object you want to detect. You can also use this tool to "erase" labeled regions.
* [Polylines](#label-with-polylines): Create lines over the object you want to detect.

## Label with Smart Labeling

<iframe width="560" height="315" src="https://www.youtube.com/embed/pPDOB6ky8VI?&wmode=opaque&rel=0" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen />

{smartLabel} is a labeling tool powered by [SAM 2](https://ai.meta.com/research/sam2/), Meta's open-source Segment Anything Model, that helps you label objects in Segmentation projects faster than using traditional methods.

To use {smartLabel}, simply select the tool (or press Q), hover over and click the object you want to select. {smartLabel} automatically detects the shape of the object and adds a gray overlay to it. To confirm that {smartLabel} detected the correct object, press **Return** (Mac) or **Enter** (Windows) to confirm.

<img src="https://mintcdn.com/landinglens/RyS1eDX1H1P0yU5b/images/label-smart-label.gif?s=61adb017cdfd20ce1873923730f8d3c8" alt="Smart Label" width="1280" height="748" data-path="images/label-smart-label.gif" />

<Info>{smartLabel} is not available in {llsf}.</Info>

### Label an Object with Smart Labeling

To label an object with {smartLabel}:

1. Click the **{smartLabel}** icon if it isn't selected, or press **q**.
2. Select the **Class** you want to label from the drop-down menu.
   <img src="https://mintcdn.com/landinglens/K_4nD7peL3kar2nE/images/smart-label-1.png?fit=max&auto=format&n=K_4nD7peL3kar2nE&q=85&s=49dd330d44cb833fe1392d52687a39da" alt="Smart Labeling" width="809" height="697" data-path="images/smart-label-1.png" />
3. Hover over the object you want to select. Smart Labeling adds a gray overlay over the object it "thinks" you want to select.
   <img src="https://mintcdn.com/landinglens/K_4nD7peL3kar2nE/images/smart-label-2.gif?s=91a0e33747c73fa637433d5428675cb0" alt="Smart Labeling" width="904" height="752" data-path="images/smart-label-2.gif" />
4. Click the object. {smartLabel} adds a green dot where you clicked. This, along with the gray overlay, help you track what regions you've selected. Clicking the object also adds a blue border to your frame, which indicates that you're using {smartLabel}.
   <img src="https://mintcdn.com/landinglens/K_4nD7peL3kar2nE/images/smart-label-3.png?fit=max&auto=format&n=K_4nD7peL3kar2nE&q=85&s=d349cdc833b59360ae3d1953cea489f1" alt="Smart Labeling" width="817" height="698" data-path="images/smart-label-3.png" />
5. If you want to add another region to the same object, hover over that region. The cursor turns into a **+** (plus).
   <img src="https://mintcdn.com/landinglens/K_4nD7peL3kar2nE/images/smart-label-4.png?fit=max&auto=format&n=K_4nD7peL3kar2nE&q=85&s=b7c781c951c2dd01aaa7657084dc4698" alt="Smart Labeling" width="818" height="703" data-path="images/smart-label-4.png" />
6. Click the object. Smart Labeling adds a gray overlay to the object and adds a green dot where you clicked.
   <img src="https://mintcdn.com/landinglens/K_4nD7peL3kar2nE/images/smart-label-5.png?fit=max&auto=format&n=K_4nD7peL3kar2nE&q=85&s=d1e47112a7f06b20b13563c341388e6d" alt="Smart Labeling" width="813" height="701" data-path="images/smart-label-5.png" />
7. You can continue to add regions using this method.
   <img src="https://mintcdn.com/landinglens/K_4nD7peL3kar2nE/images/smart-label-6.png?fit=max&auto=format&n=K_4nD7peL3kar2nE&q=85&s=652327f9ea457a8e6e3e916186df81d7" alt="Smart Labeling" width="812" height="701" data-path="images/smart-label-6.png" />
8. Once you've labeled all regions of the object, either click **Save Labels (Return)**, or press **Return** (Mac) or **Enter** (Windows).
   <img src="https://mintcdn.com/landinglens/K_4nD7peL3kar2nE/images/smart-label-7.png?fit=max&auto=format&n=K_4nD7peL3kar2nE&q=85&s=61b8a1a9fdb65403190d7e6d8419802d" alt="Smart Labeling" width="814" height="174" data-path="images/smart-label-7.png" />
9. Smart Labeling labels the object with the selected Class.
   <img src="https://mintcdn.com/landinglens/K_4nD7peL3kar2nE/images/smart-label-8.png?fit=max&auto=format&n=K_4nD7peL3kar2nE&q=85&s=54daca1c08901f2788f81cc34fcc048b" alt="Smart Labeling" width="817" height="695" data-path="images/smart-label-8.png" />

### Remove a Region from a Selection

Let's say a region gets accidentally added to your selection. While {smartLabel} is selected, you can hover over that region until the cursor turns into a **−** (minus). Then click that region. {smartLabel} removes the selection. When you're done, press **Return** (Mac) or **Enter** (Windows).

To remove a region from an object (assumes that {smartLabel} is enabled, and you just labeled an object):

1. Hover over and click the labeled region. Smart Labeling removes the overlay and adds a red dot where you clicked, which helps you track what regions you've removed.
   <img src="https://mintcdn.com/landinglens/PHcetUd-hiVs_otz/images/SmartLabel_remove.gif?s=9a67c92b6af79cde8d251812ec0c90bc" alt="SmartLabel_remove" width="1533" height="1080" data-path="images/SmartLabel_remove.gif" />
2. Continue to click selected regions until you've removed all the selections you want.
3. When you're done removing regions, press **Return** (Mac) or **Enter** (Windows).

### Tips for Labeling Multiple Objects in an Image

Let's say you're developing a model that detects tractors in construction sites. When using {smartLabel}, we recommend that you label each tractor one at a time, instead of labeling them all at once. In other words, label one tractor, and then press **Return** (Mac) or **Enter** (Windows). *Then* label the second tractor, and so on.

<img src="https://mintcdn.com/landinglens/nULG3l07sGmu7vxy/images/smart_individual_objects.gif?s=eb45527bbe12416fb6319b3d58336278" alt="smart_individual_objects" width="1453" height="1080" data-path="images/smart_individual_objects.gif" />

We don't recommend labeling all tractors at once, and then clicking **Enter**/**Return**. Doing that makes {smartLabel} think that these areas are the same object, and not the same *type* of object. If you do this, you might notice additional areas added to the object that aren't actually part of that object.

## Label with Polygons

The **polygon** tool lets you draw an outline of a shape. After the outline has been completed, the shape will be automatically filled. You can also use this tool to erase labeled regions.

To label with polygons:

1. Open the Segmentation project you want to edit.
2. Open the image you want to label.
3. Click the **Polygon** icon. (You can also press **W** on your keyboard.)
4. Select a class from the drop-down menu.
   <img src="https://mintcdn.com/landinglens/i_hGHOXkVC0R_OQG/images/polygon-1.png?fit=max&auto=format&n=i_hGHOXkVC0R_OQG&q=85&s=f57b2fd021a6e3976941175711cabeef" alt="Polygon Tool" width="786" height="707" data-path="images/polygon-1.png" />
5. Click where you want to start your shape. A blue circle displays, indicating the start of the shape.
6. Click to continue creating your shape.
7. Complete your shape by clicking the blue circle. The shape automatically fills with the color of the class.
   <img src="https://mintcdn.com/landinglens/i_hGHOXkVC0R_OQG/images/polygon-2.gif?s=1a5b633b1f3885d146d2a6be6781477b" alt="Polygon Tool" width="820" height="704" data-path="images/polygon-2.gif" />

## Label with Brushes

The **brush** tool lets you paint over the object of interest. You can also use this tool to erase labeled regions.

To label with brushes:

1. Open the Segmentation project you want to edit.
2. Open the image you want to label.
3. Click the **Brush** icon. (You can also press **B** on your keyboard.)
4. Select a class from the drop-down menu.
   <img src="https://mintcdn.com/landinglens/hjeGEKEYbDsj6EG_/images/brush-tool-1.png?fit=max&auto=format&n=hjeGEKEYbDsj6EG_&q=85&s=453892df8b450c8ce70d3dd11ded6dd7" alt="Brush Tool" width="762" height="680" data-path="images/brush-tool-1.png" />
5. Adjust the size of the line width accordingly.
6. Click and drag your cursor to "paint" over the area you want to identify.
7. Release the mouse to complete your edits.
   <img src="https://mintcdn.com/landinglens/hjeGEKEYbDsj6EG_/images/brush-tool-2.gif?s=b61f41fd422097a6a9d10deff3bf0f09" alt="Brush Tool" width="872" height="704" data-path="images/brush-tool-2.gif" />

### Remove Excess Labels with Brushes

<Info>You can also remove excess labels with Polygons. This process is similar to the procedure in this section. For more information on how to use the Polygon tool, go [here](#label-with-polygons).</Info>
To remove excess labels with a Brush:

1. Open the Segmentation project you want to edit.
2. Open the image you want to label.
3. Click the **Brush** icon. (You can also press **B** on your keyboard.)
4. Click the **Erase** icon. (You can also press **E** on your keyboard.)
   <img src="https://mintcdn.com/landinglens/hjeGEKEYbDsj6EG_/images/brush-erase-1.png?fit=max&auto=format&n=hjeGEKEYbDsj6EG_&q=85&s=e0997d75ee9bcfabc96d0f0ac2ec5d44" alt="Erase with the Brush" width="1164" height="627" data-path="images/brush-erase-1.png" />
5. Adjust the size of the eraser accordingly.
6. Click and drag your cursor over the area you want to remove.
7. Release the mouse to complete your edits.
   <img src="https://mintcdn.com/landinglens/hjeGEKEYbDsj6EG_/images/brush-erase-2.gif?s=028681c50bd7e0d3ea9d52ee631e540a" alt="Erase with the Brush" width="872" height="704" data-path="images/brush-erase-2.gif" />

## Label with Polylines

The **polyline** tool lets you create lines over the object of interest.

To label with polylines:

1. Open the Segmentation project you want to edit.
2. Open the image you want to label.
3. Click the **Polyline** icon. (You can also press **L** on your keyboard.)
4. Select the class you want to label from the drop-down menu.
   <img src="https://mintcdn.com/landinglens/i_hGHOXkVC0R_OQG/images/polyline-1.png?fit=max&auto=format&n=i_hGHOXkVC0R_OQG&q=85&s=66be7826387c6e61de276e0cf2e6f99f" alt="Polyline Tool" width="802" height="710" data-path="images/polyline-1.png" />
5. Adjust the size of the line width accordingly.
6. Click where you want to start your line.
7. Click to change the direction of your line.
8. Press **Enter** on your keyboard to complete your edits.
   <img src="https://mintcdn.com/landinglens/i_hGHOXkVC0R_OQG/images/polyline-2.gif?s=efb93e473a641e6eaf1bc7bdcba6ac24" alt="Polyline Tool" width="872" height="704" data-path="images/polyline-2.gif" />
