# Minimum Ellipse

This function block computes and draws the smallest enclosing ellipse around a provided shape (contour). It returns a visual result and numeric shape parameters useful for measurement, alignment, or further processing.

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

`Image Any` The image on which the ellipse will be drawn (input socket). Provide a copyable image so visual output is preserved.

`Contour` The contour (shape) to be enclosed by the minimum ellipse (input socket).

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

`Image` The image with the fitted ellipse drawn for visual inspection (output socket).

`Center` The center position of the fitted ellipse as a point (output socket).

`Radius1` One ellipse radius (output socket).

`Radius2` The other ellipse radius (output socket).

`Angle` The rotation angle of the ellipse in degrees (output socket).

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

This block has no interactive controls. It runs as soon as valid inputs are provided.

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

* Produces a visual overlay showing the fitted ellipse on the input image for easy verification.
* Returns geometric parameters (center, two radii, angle) useful for measurements, sorting, or downstream logic.
* Works with any valid contour extracted from a prior processing step.

## 📝 How to use <a href="#usage" id="usage"></a>

1. Provide an image into `Image Any`.
2. Provide the contour you want analyzed into `Contour`. Typical contour formats come from contour-finding blocks.
3. Read the visual result from `Image` and numerical values from `Center`, `Radius1`, `Radius2`, and `Angle` for downstream processing.

## ⚙️ What it does when run <a href="#evaluation" id="evaluation"></a>

The block fits an ellipse that minimally encloses the provided contour, draws the ellipse on a copy of the input image, and outputs the image plus numeric ellipse parameters.

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

* If you need contours from an image, use `Find Contour` or `Find Object` before this block to produce suitable `Contour` input.
* Use `Approximate Contour` to simplify complex contours before fitting an ellipse — this often yields cleaner and more stable ellipse parameters.
* Use `Image Threshold`, `Image Adaptive Threshold`, or `Blur` as preprocessing to improve contour extraction on noisy images.
* Use `Fill Contour` to generate solid shapes from edge-based contours when that helps with subsequent processing.
* Compare shapes using `Minimum Circle` or `Minimum Rotated Rectangle` when you want simpler bounding geometry alternatives.
* Visualize results with `Show Image` or save them with `Image Write` / `Image Logger` for records and reports.
* Combine with `Measure Position Distance` if you need distances between ellipse centers or other reference points.

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

* If the ellipse looks incorrect, ensure the provided `Contour` is valid (closed and with sufficient points). Try simplifying the contour with `Approximate Contour`.
* If no contour is produced upstream, confirm preprocessing steps such as thresholding or blur are applied so contour-finding blocks can detect shapes.
* If returned radii or angle seem unstable between frames, apply smoothing or use memory blocks to stabilize measurements over time.


---

# 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/shape-analysis/minimum-ellipse.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.
