> 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/shape-analysis/fill-contour.md).

# Fill Contour

This function block fills a selected contour area on an input image. Use it to mask out or keep regions defined by a contour — either filling the inside of the shape or keeping everything outside it.

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

* `Image Any` — Source image where the contour will be applied.
* `Contour` — List of contour points or a simple two-point rectangle definition.

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

* `Output Image` — Resulting image with the contour area filled or the inverse applied, depending on the control setting.

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

* `Fill Inside` — Checkbox. When checked the area inside the provided contour is preserved (everything else removed). When unchecked the inverse is preserved (inside removed, outside kept).

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

* Accepts both complex contours and a simple two-point rectangle definition for quick rectangular masks.
* Lets you choose whether to keep the inside or the outside of the contour.
* Produces a clean masked output suitable for further processing or visualization.

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

When executed the block reads the provided image and the contour points. If only two points are provided they are interpreted as opposite corners of a rectangle. The block then creates a mask from the contour and applies that mask to the input image, producing the filled/filtered result according to the `Fill Inside` selection.

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

1. Provide an image to `Image Any`.
2. Provide a contour to `Contour` (either a point list or two points for a rectangle).
3. Toggle `Fill Inside` depending on whether you want to keep the contour area or its complement.
4. Use the `Output Image` for visualization or feed it into downstream blocks.

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

* To obtain contour points from an image automatically, use `Find Contour` or `Feature Detector` before this block and feed the result into `Contour`.
* For quick manual selection of an area, pair with `Image ROI Select` or `Image ROI Polygon` to define the region and then use the resulting coordinates here.
* If you want to crop the filled area afterwards, connect the output to `Get ROI` or `Contour to Image`.
* For background removal workflows, combine `Fill Contour` with `Apply Mask` or `Background Removal (RMBG-1.4)` depending on your needs.
* Preview the result using `Show Image` to verify visually before further processing.
* Use `Blur` or `Image Threshold` before contour extraction to reduce noise and improve contour quality.

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

* If nothing changes, confirm the `Contour` contains valid points. Two points are treated as a rectangle; more points define a polygon.
* If the filled area looks inverted, toggle the `Fill Inside` checkbox.
* If the result includes unexpected regions, try preprocessing with `Image Threshold` or `Blur` and re-extract the contour with `Find Contour`.
