# Image ROI Center

This function block is utilized to crop an image based on specified center coordinates, width, and height. It allows users to define a specific region of interest (ROI) within an image for further processing.

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

`Image Any` The input image from which the region of interest will be extracted.

`Center` A point representing the center of the region you want to crop.

`Width` The width of the cropping area.

`Height` The height of the cropping area.

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

`Image Any` The cropped image extracted from the specified region of interest.

`Rectangle` The coordinates of the rectangular area that defines the ROI.

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

This function block does not have direct controls, as input parameters will be directly specified through the connected nodes.

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

`Flexible Cropping` Allows specifying the cropping area dynamically based on the center coordinates and adjustable dimensions.

`Output Rectangle Coordinates` Outputs the coordinates of the cropped rectangle, providing useful information about the cropping area for further processing or annotation.

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

1. **Connect Input Image**: Link an image to the `Image Any` input.
2. **Specify Center**: Provide a point for the center of the cropping area in the `Center` input.
3. **Set Dimensions**: Define the desired `Width` and `Height` for the cropping area.
4. **Evaluate Block**: Run the block to process the image and obtain the cropped output along with the rectangle coordinates.

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

When executed, this function block will output the area of the image defined by the center point and specified dimensions, resulting in a new image that is a cropped version of the original.

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

<details>

<summary>Setting Center Coordinate</summary>

Make sure the center coordinates are valid within the bounds of the original image to prevent errors.

</details>

<details>

<summary>Ensure Valid Dimensions</summary>

Ensure that the defined width and height of the cropping area do not exceed the dimensions of the original image.

You may want to add a step using the `Image Resolution and Channel Value` block to correctly check the original dimensions.

</details>

<details>

<summary>Using with Other Functions</summary>

This block works well with the `Show Image` block for visual confirmation of the ROI after cropping.

</details>

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

<details>

<summary>Cropped Image is Empty</summary>

If the resulting cropped image appears empty, ensure that the center coordinates and dimensions are set correctly for the area you intend to crop.

</details>

<details>

<summary>Coordinates Out of Bounds</summary>

If you encounter an error regarding out-of-bound coordinates, double-check the inputs to confirm they remain within the boundaries of the original image dimensions.

</details>
