> For the complete documentation index, see [llms.txt](https://docs.augelab.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.augelab.com/function-blocks/blocks-reference/detections-shapes/roi-processing/image-roi.md).

# 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 <a href="#inputs" id="inputs"></a>

`Image Any` Provide the source image to be cropped.

## 📤 Outputs <a href="#outputs" id="outputs"></a>

`Image Any` Cropped image corresponding to the selected rectangle.

`Rectangle` Coordinates of the selected ROI as a rectangle shape.

## 🕹️ Controls <a href="#controls" id="controls"></a>

`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 <a href="#features" id="features"></a>

* 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 <a href="#usage" id="usage"></a>

1. Connect an image-producing block to the `Image Any` input.
2. Observe the `Input Image Size (H, W)` label to confirm dimensions.
3. Adjust the `Width` slider min/max to set horizontal crop bounds.
4. Adjust the `Height` slider min/max to set vertical crop bounds.
5. Use the outputs where needed: pass the cropped image to analysis blocks or use the rectangle coordinates for visualization.

## 💡 Tips and Tricks <a href="#tips-and-tricks" id="tips-and-tricks"></a>

* To visually inspect the selected ROI while tuning sliders, send the `Image Any` output to the `Show Image` block.
* If the input image is very large, place an `Image Resizer` block before this block to speed up interactive slider adjustments.
* Use `Image ROI Select` or `Image ROI Select Multi` if 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`, or `Blob Detector` to reduce false matches and speed up processing.
* To save examples of the ROI or log them, connect the cropped image output to `Image Logger` or `Image Write`.
* To mark the ROI on the original image for visualization, use the rectangle output with `Draw Rectangle` and then preview using `Show Image`.
* Combine with `Histogram On Line` or `Histogram On Curve` for profile analysis limited to the cropped area.
* Use the rectangle coordinates with ROI-aware blocks like `Get ROI` or `Check Area` to build downstream logic based on object positions inside the selected region.

## 🛠️ Troubleshooting <a href="#troubleshooting" id="troubleshooting"></a>

* 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.
