Minimum Rotated Rectangle

This function block computes the smallest rotated rectangle that encloses a given shape (contour) in an image. It is useful for measuring oriented object size and orientation, and for visualizing bounding geometry that is not axis-aligned.

πŸ“₯ Inputs

  • Image The source image used for visualization and reference.

  • Contour Shape/contour used to calculate the minimum rotated rectangle.

πŸ“€ Outputs

  • Image The source image annotated with the computed rotated rectangle and contour.

  • Center Center point of the computed rotated rectangle.

  • Width Width value of the rotated rectangle.

  • Height Height value of the rotated rectangle.

  • Angle Rotation angle of the rectangle (orientation).

  • Contour The contour representation of the rotated rectangle (as a shape output).

  • Rectangle Image A separate visualization showing the cropped/rectified rectangle region.

πŸ•ΉοΈ Controls

This function block has no user-editable controls. It runs automatically when both inputs are provided.

🎯 Features

  • Computes a minimum-area rectangle that may be rotated relative to image axes.

  • Provides geometric measurements: center, width, height and angle.

  • Visualizes results directly on the source image and as a separate rectangle image.

  • Outputs the rectangle as a contour/shape so it can be routed to other blocks for further processing.

βš™οΈ Running mechanism

When an image and a contour are provided, the block analyses the contour shape to determine the smallest-area rectangle that encloses it. The block then produces numeric measurements for size and orientation, draws the rectangle on the image for immediate visual feedback, and also provides the rectangle as a separate shape and image output. If no valid contour is provided, the block will not produce geometric results (it will emit empty or default outputs).

πŸ“ Usage instructions

  1. Provide a contour input that represents the object of interest (see Tips and Tricks for how to obtain contours).

  2. Feed the same reference image (or a copy) to the Image input if you want annotated visualization.

  3. Read values from the Center, Width, Height, and Angle outputs for measurements or decision logic.

  4. Use the Rectangle Image output when you need a cropped or rectified view of the detected object.

πŸ’‘ Tips and Tricks

  • To obtain contours from raw images, combine with Find Contour or Feature Detector to extract object contours before feeding into this block.

  • If contours are noisy or contain many points, use Approximate Contour to simplify the contour and improve measurement stability.

  • For shapes that are better enclosed by convex hulls, try using Hull Convex first and feed the hull into this block.

  • Compare different enclosing geometries by pairing this block with Minimum Circle, Minimum Ellipse, or Minimum Rectangle to pick the best fit for your application.

  • Use Image ROI Select or Image ROI to crop the region before contour extraction when you only care about a sub-region of the image.

  • Visualize or export results with Draw Rectangle or Draw Result On Image for clear overlays in reports or UI.

πŸ› οΈ Troubleshooting

  • No measurements produced: ensure a valid contour is connected to the Contour input and that the contour is not empty.

  • Unexpected orientation or size: try simplifying the contour with Approximate Contour or verify that the contour corresponds to the intended object (use Contour to Image to inspect).

  • Rectangle not covering object correctly: check the contour extraction step for holes or disconnected fragments; consider using Hull Convex to create an envelope before measurement.

Last updated

Was this helpful?