Blog/Tutorials
Tutorials4 min read

Polygon Annotation for Segmentation Tasks

How to configure polygon drawing tools for image segmentation, with tips for complex shapes and overlapping regions.

By Potato Team·

Polygon Annotation for Segmentation Tasks

Polygon annotation enables pixel-precise object boundaries for semantic and instance segmentation. This guide covers configuration, annotation techniques, and best practices for complex segmentation tasks.

When to Use Polygons vs Bounding Boxes

Use Polygons WhenUse Bounding Boxes When
Precise boundaries neededRough localization sufficient
Irregular object shapesObjects are roughly rectangular
Training segmentation modelsTraining detection models
Overlapping objectsNon-overlapping objects
Higher accuracy requiredSpeed is priority

Basic Polygon Setup

annotation_task_name: "Image Segmentation"
 
data_files:
  - "data/images.json"
 
annotation_schemes:
  - annotation_type: image_annotation
    tools: [polygon]
    name: segments
    description: "Draw polygons around each object"
    labels:
      - name: road
        color: "#808080"
      - name: sidewalk
        color: "#F5F5DC"
      - name: building
        color: "#8B4513"
      - name: vegetation
        color: "#228B22"
      - name: sky
        color: "#87CEEB"
      - name: vehicle
        color: "#FF6B6B"
      - name: person
        color: "#4ECDC4"

Drawing Polygons

Basic Workflow

  1. Select a label from the toolbar
  2. Click to place vertices around the object
  3. Double-click or press Enter to close the polygon
  4. Adjust vertices by dragging
  5. Add points by clicking on edges

Keyboard Shortcuts

Potato provides built-in keyboard shortcuts for polygon editing:

  • Enter: Close the current polygon
  • Escape: Cancel drawing or deselect
  • Delete: Remove selected vertex or polygon
  • +/-: Zoom in/out
  • Space + drag: Pan the image

Handling Complex Scenarios

Overlapping Objects

For tasks with overlapping objects, annotators can draw multiple polygons that overlap. Each polygon is stored separately in the output, allowing for instance-level annotation where objects may occlude each other.

Tips for Complex Boundaries

When annotating objects with complex boundaries:

  1. Use more vertices for curved edges to capture the shape accurately
  2. Zoom in when tracing detailed boundaries
  3. Work systematically around the object perimeter
  4. Use the edit mode to refine vertex positions after initial drawing

Semantic Segmentation Setup

For full-image segmentation:

annotation_task_name: "Semantic Segmentation"
 
data_files:
  - "data/images.json"
 
annotation_schemes:
  - annotation_type: image_annotation
    tools: [polygon]
    name: semantic_segments
    description: "Segment the entire image"
    labels:
      - name: background
        color: "#000000"
      - name: road
        color: "#808080"
      - name: sidewalk
        color: "#F5F5DC"
      - name: building
        color: "#8B4513"
      - name: vegetation
        color: "#228B22"
      - name: sky
        color: "#87CEEB"
      - name: person
        color: "#4ECDC4"
      - name: vehicle
        color: "#FF6B6B"

Instance Segmentation Setup

For individual object instances:

annotation_task_name: "Instance Segmentation"
 
data_files:
  - "data/images.json"
 
annotation_schemes:
  - annotation_type: image_annotation
    tools: [polygon]
    name: instances
    description: "Draw polygons around each object instance"
    labels:
      - name: person
        color: "#4ECDC4"
      - name: car
        color: "#FF6B6B"
      - name: dog
        color: "#FFEAA7"

Each polygon drawn will be stored as a separate annotation, allowing you to track individual instances of each object class.

Complete Configuration Example

annotation_task_name: "Cityscapes-style Segmentation"
 
data_files:
  - "data/urban_scenes.json"
 
annotation_schemes:
  - annotation_type: image_annotation
    tools: [polygon]
    name: segments
    description: "Segment all objects following Cityscapes protocol"
    labels:
      # Flat
      - name: road
        color: "#804080"
      - name: sidewalk
        color: "#F423E8"
      # Construction
      - name: building
        color: "#464646"
      - name: wall
        color: "#666666"
      - name: fence
        color: "#BE9999"
      # Nature
      - name: vegetation
        color: "#6B8E23"
      - name: terrain
        color: "#98FB98"
      # Sky
      - name: sky
        color: "#4682B4"
      # Human
      - name: person
        color: "#DC143C"
      - name: rider
        color: "#FF0000"
      # Vehicle
      - name: car
        color: "#00008B"
      - name: truck
        color: "#000046"
      - name: bus
        color: "#003C64"
      - name: motorcycle
        color: "#0000E6"
      - name: bicycle
        color: "#770B20"

Output Format

Polygon annotations are saved in the annotation output with coordinates for each vertex:

{
  "id": "img001",
  "annotations": {
    "segments": [
      {
        "label": "road",
        "points": [[0, 600], [100, 580], [200, 590], [0, 600]]
      },
      {
        "label": "car",
        "points": [[450, 400], [520, 400], [520, 480], [450, 480]]
      }
    ]
  }
}

Tips for Quality Polygons

  1. Zoom in: Work at 2x or higher for detailed boundaries
  2. Use keyboard shortcuts: Much faster than clicking tools
  3. Start with major features: Rough outline first, then refine
  4. Vertex economy: Use minimum points needed for accuracy
  5. Regular breaks: Detailed polygon work causes fatigue

Next Steps


See /docs/features/image-annotation for complete polygon documentation.