# Image ROI Select

This function block provides an interactive image area where you can draw a rectangular crop (ROI) using the mouse. Use it to quickly define a region of interest for downstream processing, inspection, or saving.

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

`Image Any` Connect an image to this socket to enable interactive selection. The image can be RGB or grayscale.

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

`Image Any` A visualization of the source image with the selected rectangle drawn on it.

`Rectangle` The rectangle coordinates of the selected ROI (top-left and bottom-right points).

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

`Image` Click and drag inside this display area to draw the ROI rectangle. Release the mouse to finalize the selection.

`Last Selection` The last drawn rectangle is kept and shown on the image display after running the block. The selection is preserved across saves and reloads.

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

* Interactive click-and-drag selection for fast ROI definition.
* Visual feedback with a clear green rectangle drawn over the image.
* Outputs both the cropped image region and the rectangle coordinates for use in other blocks.
* Selection persists so you can tweak downstream processing without reselecting immediately.

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

1. Connect an image-producing block to the `Image Any` input.
2. Run the system once so the image appears in the block.
3. Click and drag inside the `Image` area to draw a rectangle over the region you want to crop. Release to confirm.
4. Downstream blocks will receive the cropped image and the rectangle coordinates when this block is evaluated.

Examples of common workflows:

* Preview and fine-tune a crop prior to saving frames with `Image Write` or `Image Logger`.
* Crop a region before sending it to `Find Object` or `Template Match` for faster, more focused detection.
* Use the cropped output with `Histogram On Line` or `Color Density Percentage` to analyze a specific part of the image.

## 📊 Evaluation <a href="#evaluation" id="evaluation"></a>

When evaluated, the block returns:

* a copy of the image with the rectangle drawn (`Image Any`), and
* the rectangle coordinates (`Rectangle`).\
  If no selection is made, the full image area is returned as the ROI.

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

* To inspect the crop in a larger window, pair this block with `Show Image`.
* If you need polygonal ROIs instead of rectangular ones, use `Image ROI Polygon` or `Image ROI Polygon Multi`.
* Combine with `Image Resize` when a fixed processing size is required by downstream blocks.
* Save selected frames or datasets by connecting the cropped output to `Image Write` or `Image Logger`.
* Use `Apply Mask` if you want to further mask out parts of the cropped region before analysis.

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

* No image appears: ensure an image-producing block is connected to `Image Any` and the system has been run once.
* Selection does not update visually: try running the block after drawing; the display refreshes when evaluated.
* ROI coordinates seem out of range: make sure the source image resolution is the same as the one displayed. If you resize upstream images, reselect the ROI.
* Need repeated or multiple ROIs: use `Image ROI Polygon Multi` to define multiple regions or save your selection and reapply it with downstream flow control blocks.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.augelab.com/function-blocks/detections-shapes/roi-processing/image-roi-select.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
