Contour to Image
This function block extracts a rectangular image region around a given contour. Provide a source image and a contour (shape) and the block returns a cropped rectangular image that contains the contour. It is useful when you want to isolate and inspect a single object detected in a larger picture.
π₯ Inputs
Imageβ Source image that contains the object to be cropped. Can be color or grayscale.Contourβ Shape/contour describing the object boundary. Provide a contour obtained from a contour-finding or shape-processing block.
π€ Outputs
Imageβ Cropped rectangular image containing the area around the provided contour.
πΉοΈ Controls
No Controlsβ This block has no interactive widgets. It works by receiving its inputs and producing the cropped image automatically.
βοΈ Running mechanism
When the block runs it looks at the provided contour and determines a rectangular area that encloses the contour. That area is extracted from the source image and returned as the block output. If the contour is rotated or irregular, the block fits a rectangle that contains the contour and returns a rectangular crop so you can continue downstream processing more easily.
β¨ Features
Extracts a focused rectangular image around a contour so further analysis becomes simpler.
Works with contours produced by various detection and shape-analysis blocks.
Returns a ready-to-use image output for visualization, recognition, or saving.
π How to use
Produce contours from your image (for example by thresholding and contour detection).
Connect the source image to the
Imageinput and the chosen contour to theContourinput.The block outputs the cropped rectangular image at the
Imageoutput. Use it as input for other blocks (e.g., recognition, OCR, or saving).
π‘ Tips and Tricks
To generate contours before this block, use the
Find Contourblock.If you need a simplified polygon before cropping, try
Approximate Contourto reduce corner count.For rotated objects, compare results with
Minimum Rotated RectangleorMinimum Rectangleto choose the best enclosing shape for your workflow.Preview the cropped result quickly with the
Show Imageblock.After cropping, you can apply
Image Resizeto normalize sizes, orAuto Contrast/Denoisingto prepare the crop for downstream tasks.To save crops automatically, connect this block's output to
Image LoggerorImage Write.
π οΈ Troubleshooting
If the output is unexpected or empty, verify that the
Contourinput contains a valid contour (notNone). UseFind ContourorApproximate Contourto produce valid contours.If the crop looks clipped, check that the contour coordinates lie within the source image bounds. Adjust preprocessing or contour selection if necessary.
If the object appears rotated or skewed and you need a different perspective, experiment with
Minimum Rotated Rectangleor use a perspective-aware workflow (crop thenAuto Alignment/Perspective Transform) before further analysis.
Last updated
Was this helpful?