> 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-select.md).

# Image ROI Select

This function block lets you select a single rectangular region of interest (ROI) interactively by dragging on the image preview. It is ideal for cropping an area from an image for further processing or inspection.

## 📥 Inputs <a href="#inputs" id="inputs"></a>

`Image Any` The image to crop. Connect a grayscale or color image to define the area that can be selected.

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

`Image Any` The cropped image corresponding to the selected rectangle.

`Rectangle` The pixel rectangle describing the selected area (top-left and bottom-right coordinates).

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

`Image Preview` The interactive preview where you create and edit the rectangular ROI by mouse.

`Drag` Create a rectangle by dragging on the preview, or drag inside the rectangle to move it.

`Edge / Corner Drag` Resize the rectangle by dragging an edge or corner.

`Ctrl` Hold to force creation of a new rectangle even if an existing rectangle is present.

## 🎯 Features <a href="#features" id="features"></a>

* Interactive rectangle creation, move and resize directly on the image preview.
* Visual overlay shows the current rectangle and highlights it during interaction.
* Accepts single or repeated selection; the most recent ROI is used for output.
* Cropped result is returned immediately as an image along with rectangle coordinates.
* The selected rectangle is preserved so the same ROI can be restored when the project is reloaded.

## ⚙️ Running mechanism <a href="#how-it-works" id="how-it-works"></a>

* Provide an image to the `Image Any` input and run the scenario once to load the image into the preview.
* Use the preview to `Drag` and draw a rectangle. Drag inside the rectangle to move it, or drag edges/corners to resize.
* The block computes the pixel coordinates of the selected rectangle and outputs:
  * the cropped image extracted from those coordinates via `Image Any`
  * the rectangle coordinates via `Rectangle`
* The preview overlay updates live while you create or edit the ROI.

## 📝 Usage instructions <a href="#usage" id="usage"></a>

1. Connect an image-producing block to the `Image Any` input and run once to populate the preview.
2. Draw the ROI by clicking and dragging on the preview.
3. Move or resize the ROI as needed.
4. Hold `Ctrl` while dragging to create a fresh rectangle.
5. Use the outputs to feed the cropped image or the rectangle coordinates to downstream blocks.

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

* Combine with `Show Image` to open the cropped result in a larger viewer for inspection.
* If you need multiple editable ROIs, use `Image ROI Select Multi` instead of this block.
* Use `Image Resize` after this block to normalize crop sizes before running detection or analysis.
* Feed the cropped output into `Find Object` when you want to run template matching only inside the selected area — this reduces false matches and speeds processing.
* Save important crops using `Image Logger` or `Image Write` to record examples for later review or training data.
* To visualize detections or coordinates back on the original image, use `Draw Rectangle` downstream with the `Rectangle` output.

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

* If the preview is empty, make sure the producing block is connected and that you have run the pipeline once to load image data.
* If selection appears outside the image, verify the input image dimensions and redraw the ROI inside the preview area.
* For final processing, confirm the cropped image resolution is appropriate for downstream blocks (use `Image Resize` if needed).
