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
Connect an image-producing block to
Input Image.Run once so the image is visible in the interactive area.
Left-click on the image to add polygon vertices in order.
Use
Uto undo the last point orCto clear all points.After defining the polygon, the block outputs the cropped polygon image on
Image Anyand the polygon coordinates onPolygon.
π 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 Anyoutput to theShow Imageblock.If you need multiple crop areas, use the
Image ROI Polygon Multiblock to define and manage several polygons.To quickly define a rectangular ROI instead of a polygon, combine this block with
Image ROI SelectorImage ROIfor faster rectangle-based cropping.Use the polygon coordinates with
Apply Maskto 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 ObjectorContour to Imageto focus processing only inside the selected area.When saving examples or records, attach the cropped output to
Image LoggerorImage Writeto keep dataset images of your ROI.If you need a fixed image size for downstream models, add
Image Resizeafter the crop to normalize dimensions.
π οΈ Troubleshooting
No image visible in the interactive area: ensure an image-producing block is connected to
Input Imageand 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?