Image ROI Polygon

This function block lets you draw a polygon directly on an image to define a region of interest (ROI). Use left mouse clicks to add points, then extract the cropped polygon area or a polygon shape for downstream processing.

πŸ“₯ Inputs

Input Image Input socket that accepts any image to draw the polygon on.

πŸ“€ Outputs

Image Any Output socket that provides the cropped image inside the drawn polygon (or None if no polygon defined).

Polygon Output socket that provides the polygon point list as a shape value suitable for other ROI-aware blocks.

πŸ•ΉοΈ Controls

Interactive Image Area Click on the image to add polygon vertices. The interactive area also shows visual feedback (points, connecting lines and a translucent highlight of the polygon).

U Press this key to undo the last added point.

C Press this key to clear all points and start over.

🎨 Features

  • Visual point/edge drawing with immediate feedback: points and connecting lines are drawn on the image as you add vertices.

  • Highlighted polygon area overlay for quick preview of the selected ROI.

  • Returns both the cropped image inside the polygon and the polygon coordinates as an output shape for further processing.

  • Supports serialization: polygon points are kept when saving/loading the scenario so you can restore your ROI.

πŸ“ Usage Instructions

  1. Connect an image-producing block to Input Image.

  2. Run once so the image is visible in the interactive area.

  3. Left-click on the image to add polygon vertices in order.

  4. Use U to undo the last point or C to clear all points.

  5. After defining the polygon, the block outputs the cropped polygon image on Image Any and the polygon coordinates on Polygon.

πŸ“Š Evaluation

When evaluated, the block updates the interactive image preview and, if a polygon exists, outputs:

  • the cropped polygon image (tight bounding box of the polygon), and

  • the polygon coordinates as a shape list ready for downstream blocks.

If no polygon is drawn the Image Any output will be None.

πŸ’‘ Tips and Tricks

  • To visually inspect the selected ROI in larger detail, send the Image Any output to the Show Image block.

  • If you need multiple crop areas, use the Image ROI Polygon Multi block to define and manage several polygons.

  • To quickly define a rectangular ROI instead of a polygon, combine this block with Image ROI Select or Image ROI for faster rectangle-based cropping.

  • Use the polygon coordinates with Apply Mask to mask the original image while preserving full canvas size (useful when you want to keep image alignment).

  • Send the cropped ROI to analysis or detection blocks like Find Object or Contour to Image to focus processing only inside the selected area.

  • When saving examples or records, attach the cropped output to Image Logger or Image Write to keep dataset images of your ROI.

  • If you need a fixed image size for downstream models, add Image Resize after the crop to normalize dimensions.

πŸ› οΈ Troubleshooting

  • No image visible in the interactive area: ensure an image-producing block is connected to Input Image and run once to populate the preview.

  • Polygon not producing an output: make sure at least two points are defined; the block only produces a crop when a polygon is formed.

  • Cropped area appears empty or transparent: verify the polygon was drawn within image bounds and that the source image is not all zeros.

  • Saved project loses polygon points: confirm the project was saved after drawing (this block serializes the point list, but you must save the scenario to persist it).

Last updated

Was this helpful?