Draw Rectangle

This function block overlays one or more rectangles on an input image based on provided rectangle coordinates. Each rectangle can be colored to indicate a status (e.g., OK vs NOK). Use it to visualize detection results, highlight regions of interest, or annotate images before saving or display.

πŸ“₯ Inputs

Image Any - Source image that will be annotated.

Rectangle - Single rectangle or a list of rectangles. Accepts coordinates in pair format ((y0, x0), (y1, x1)) or equivalent bounding-pair form. Multiple rectangles are supported.

Status - Optional boolean or list of booleans to control rectangle color. When provided, TRUE draws a green rectangle and FALSE draws a red rectangle. If multiple rectangles are provided, supply a matching list of statuses to color individually.

πŸ“€ Outputs

Image Any - The annotated image with rectangles drawn on a copy of the input image.

πŸ•ΉοΈ Controls

No Controls - This block has no additional UI widgets. All behavior is controlled via its inputs.

βš™οΈ How it runs

  • The block takes the current image and makes a copy to preserve the original.

  • It reads the provided Rectangle input. If a list is provided, each rectangle is processed in order.

  • For each rectangle, the block reads the corresponding Status (single or list). A TRUE status results in a green rectangle; FALSE results in a red rectangle.

  • Rectangles are drawn with a visible border thickness so they are easy to spot on the result image.

  • The resulting annotated image is returned via the Image Any output.

✨ Features

  • Supports single or multiple rectangle inputs.

  • Optional per-rectangle status coloring (green for TRUE, red for FALSE).

  • Works on any image format accepted by the system.

  • Non-destructive: original image is preserved; annotations are applied to a copy.

πŸ“ Usage suggestions

  • Provide rectangle coordinates as bounding pairs ((y0, x0), (y1, x1)) for correct placement.

  • When drawing multiple rectangles, supply a list of matching statuses to color each rectangle independently.

  • Combine with preview and export blocks to review and save annotated images.

πŸ’‘ Tips and Tricks

  • Combine with Find Object or Object Detection to draw detection boxes returned by those blocks and visualize detected items.

  • Use Rectangles in Rectangle to filter or validate rectangles before drawing (for example, ignore boxes outside a region of interest).

  • Crop the image first with Image ROI Select or Image ROI to reduce clutter and focus annotations on a specific area.

  • After annotating, preview the result with Show Image and save using Image Write or Image Logger.

  • If you need side-by-side comparisons (original vs annotated), use Image Concatenate or Collage Images.

  • If coordinates come from other logic or data operations, use Parse Data Dictionary, Get Element, or Replace None to prepare inputs robustly.

πŸ› οΈ Troubleshooting

  • Incorrect coordinate format or ordering may place rectangles in unexpected positions. Verify coordinates are provided as top-left and bottom-right pairs.

  • If rectangles are not visible, check image resolution and rectangle coordinates with Image Resolution and Channel Value or Get Dimension.

  • For multiple rectangles, ensure the Status list length matches the number of rectangles to avoid mismatched coloring.

  • If you want text overlays alongside rectangles, use Draw Result On Image after this block to place condition text near drawn boxes.

Last updated

Was this helpful?