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

  • Image Any β€” Source image where the contour will be applied.

  • Contour β€” List of contour points or a simple two-point rectangle definition.

πŸ“€ Outputs

  • Output Image β€” Resulting image with the contour area filled or the inverse applied, depending on the control setting.

πŸ•ΉοΈ Controls

  • 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

  • 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

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

  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

  • 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

  • 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.

Last updated

Was this helpful?