Image ROI
This function block lets you crop a region of interest from an input image using horizontal range sliders. Adjust the Width and Height sliders to define a rectangular crop; the block outputs the cropped image and the rectangle coordinates for further processing.
π₯ Inputs
Image Any Provide the source image to be cropped.
π€ Outputs
Image Any Cropped image corresponding to the selected rectangle.
Rectangle Coordinates of the selected ROI as a rectangle shape.
πΉοΈ Controls
Width Horizontal range slider to set left/right crop limits (min and max).
Height Vertical range slider to set top/bottom crop limits (min and max).
Input Image Size (H, W) Informational label that shows the input image dimensions and updates the sliders' ranges automatically.
h2 id="running-mechanism">βοΈ Running mechanism
When the block receives an input image, it reads the image dimensions and updates the Width and Height slider ranges to match the image size. The sliders provide integer min/max values which define the crop rectangle. On evaluation the block returns the cropped image and a rectangle shape that represents the ROI.
π― Features
Dynamic slider ranges that automatically adapt to the connected image size.
Returns both the cropped image and the rectangle coordinates for downstream use.
Preserves image channel layout (color or grayscale) in the cropped result.
Remembers and restores the input image size when saving/loading scenarios (serialization support).
π Usage instructions
Connect an image-producing block to the
Image Anyinput.Observe the
Input Image Size (H, W)label to confirm dimensions.Adjust the
Widthslider min/max to set horizontal crop bounds.Adjust the
Heightslider min/max to set vertical crop bounds.Use the outputs where needed: pass the cropped image to analysis blocks or use the rectangle coordinates for visualization.
π‘ Tips and Tricks
To visually inspect the selected ROI while tuning sliders, send the
Image Anyoutput to theShow Imageblock.If the input image is very large, place an
Image Resizerblock before this block to speed up interactive slider adjustments.Use
Image ROI SelectorImage ROI Select Multiif you prefer selecting crop areas with the mouse instead of sliders, then feed the resulting rectangle into this block or use its outputs downstream.For focused detection on the cropped area, feed the cropped image into detector blocks such as
Find Object,Object Detection, orBlob Detectorto reduce false matches and speed up processing.To save examples of the ROI or log them, connect the cropped image output to
Image LoggerorImage Write.To mark the ROI on the original image for visualization, use the rectangle output with
Draw Rectangleand then preview usingShow Image.Combine with
Histogram On LineorHistogram On Curvefor profile analysis limited to the cropped area.Use the rectangle coordinates with ROI-aware blocks like
Get ROIorCheck Areato build downstream logic based on object positions inside the selected region.
π οΈ Troubleshooting
If sliders do not cover the full image extent, confirm an image is connected and visible in the
Input Image Size (H, W)label β the sliders update only after the image is received.If the cropped output is empty or black, ensure the slider min/max values define a non-zero area and are within image bounds.
If downstream blocks expect a specific channel format (grayscale vs RGB), use color conversion or an
Image Resizer/ preprocessing block before or after cropping to match expected input formats.
Last updated
Was this helpful?