Skip to content

Polygon Visualization

Class: PolygonVisualizationBlockV1

Source: inference.core.workflows.core_steps.visualizations.polygon.v1.PolygonVisualizationBlockV1

Draw polygon outlines around detected objects that follow the exact shape of object masks, providing precise boundary visualization for instance segmentation results.

How This Block Works

This block takes an image and instance segmentation predictions (which include segmentation masks) and draws polygon outlines that precisely follow the shape of each detected object. The block:

  1. Takes an image and instance segmentation predictions as input (predictions must include mask data)
  2. Converts segmentation masks to polygon coordinates that trace the object boundaries
  3. Applies color styling based on the selected color palette, with colors assigned by class, index, or track ID
  4. Draws polygon outlines with the specified thickness using the PolygonAnnotator
  5. Returns an annotated image with polygon outlines overlaid on the original image

The block extracts the exact shape of each object from its segmentation mask and draws polygon outlines that follow these precise boundaries. This provides much more accurate visualization than bounding boxes, as polygons conform to the actual object shape rather than enclosing them in rectangles. If mask data is not available, the block falls back to drawing bounding boxes. The polygon outlines can be customized with different thickness values and color palettes, allowing you to clearly distinguish between different objects or object classes.

Common Use Cases

  • Precise Object Boundary Visualization: Visualize the exact shape and boundaries of segmented objects for applications requiring accurate object outlines, such as medical imaging, manufacturing quality control, or precise measurement workflows
  • Instance Segmentation Model Validation: Verify and debug instance segmentation model performance by visualizing how well polygon predictions match object boundaries, identify segmentation errors, and validate mask quality
  • Irregular Shape Analysis: Visualize objects with irregular or non-rectangular shapes (e.g., people, animals, complex machinery parts) where bounding boxes would be inaccurate or misleading
  • Overlapping Object Visualization: Clearly show object boundaries when multiple objects overlap, as polygons accurately represent each object's shape without the ambiguity of overlapping bounding boxes
  • Shape-Based Quality Control: Inspect object shapes and boundaries in manufacturing, agriculture, or quality assurance workflows where precise object contours are critical for defect detection or classification
  • Scientific and Medical Imaging: Visualize segmented regions in medical imaging, microscopy, or scientific analysis where accurate boundary representation is essential for measurement, analysis, or diagnosis

Connecting to Other Blocks

The annotated image from this block can be connected to:

  • Other visualization blocks (e.g., Label Visualization, Mask Visualization, Bounding Box Visualization) to combine polygon outlines with additional annotations for comprehensive visualization
  • Data storage blocks (e.g., Local File Sink, CSV Formatter, Roboflow Dataset Upload) to save annotated images with polygon outlines for documentation, reporting, or training data validation
  • Webhook blocks to send visualized results with polygon outlines to external systems, APIs, or web applications for display in dashboards or analysis tools
  • Notification blocks (e.g., Email Notification, Slack Notification) to send annotated images with polygon outlines as visual evidence in alerts or reports
  • Video output blocks to create annotated video streams or recordings with polygon outlines for live monitoring, tracking, or post-processing analysis

Type identifier

Use the following identifier in step "type" field: roboflow_core/polygon_visualization@v1to add the block as as step in your workflow.

Properties

Name Type Description Refs
name str Enter a unique identifier for this step..
copy_image bool Enable this option to create a copy of the input image for visualization, preserving the original. Use this when stacking multiple visualizations..
color_palette str Select a color palette for the visualised elements..
palette_size int Specify the number of colors in the palette. This applies when using custom or Matplotlib palettes..
custom_colors List[str] Define a list of custom colors for bounding boxes in HEX format..
color_axis str Choose how bounding box colors are assigned..
thickness int Thickness of the polygon outline in pixels. Higher values create thicker, more visible outlines..

The Refs column marks possibility to parametrise the property with dynamic values available in workflow runtime. See Bindings for more info.

Available Connections

Compatible Blocks

Check what blocks you can connect to Polygon Visualization in version v1.

Input and Output Bindings

The available connections depend on its binding kinds. Check what binding kinds Polygon Visualization in version v1 has.

Bindings
  • input

    • image (image): The image to visualize on..
    • copy_image (boolean): Enable this option to create a copy of the input image for visualization, preserving the original. Use this when stacking multiple visualizations..
    • predictions (Union[instance_segmentation_prediction, rle_instance_segmentation_prediction]): Instance segmentation predictions containing mask data. The block converts masks to polygon outlines that follow the exact shape of each detected object..
    • color_palette (string): Select a color palette for the visualised elements..
    • palette_size (integer): Specify the number of colors in the palette. This applies when using custom or Matplotlib palettes..
    • custom_colors (list_of_values): Define a list of custom colors for bounding boxes in HEX format..
    • color_axis (string): Choose how bounding box colors are assigned..
    • thickness (integer): Thickness of the polygon outline in pixels. Higher values create thicker, more visible outlines..
  • output

    • image (image): Image in workflows.
Example JSON definition of step Polygon Visualization in version v1
{
    "name": "<your_step_name_here>",
    "type": "roboflow_core/polygon_visualization@v1",
    "image": "$inputs.image",
    "copy_image": true,
    "predictions": "$steps.instance_segmentation_model.predictions",
    "color_palette": "DEFAULT",
    "palette_size": 10,
    "custom_colors": [
        "#FF0000",
        "#00FF00",
        "#0000FF"
    ],
    "color_axis": "CLASS",
    "thickness": 2
}