Shape Detector
This function block finds a distinct shape in a color image by filtering, thresholding and contour analysis. It returns a visualized result and numeric shape descriptors that can be used by downstream blocks.
π₯ Inputs
Image This input socket accepts a color image to analyze.
π€ Outputs
Filtered Image Output socket that provides the binary or filtered image used for contour extraction (visual feedback for preprocessing).
Contoured Image Output socket that provides the original image with detected contour drawn.
Shape Image Output socket that provides the cropped or separated shape visualization.
Border Coordinate Output socket that provides the contour coordinate(s) that form the detected border.
Shape Width Output socket that provides the detected shape width.
Shape Height Output socket that provides the detected shape height.
Shape Position Output socket that provides the detected shape center position.
Shape Rotation Output socket that provides the detected shape rotation angle.
πΉοΈ Controls
Blur coefficient Slider control to tune median blur strength before thresholding. Use to reduce noise while preserving edges.
Clear spots parameter Slider control to set morphological closing size. Use to remove small holes or join object parts.
Auto threshold ? Checkbox control to enable automatic thresholding (Otsu). When enabled, manual threshold range is disabled.
Threshold range Two-ended slider control to set manual threshold low/high values. Active when Auto threshold ? is unchecked.
Shape area range % Two-ended slider control to limit detected contours by relative area (percentage of image). Use to ignore very small or very large objects.
βοΈ Running mechanism
When an image is provided to the
Imageinput socket, the block applies the selected blur, thresholding (auto or manual) and morphological closing.Contours are extracted from the filtered image. The block selects contours that fall into the configured
Shape area range %and returns the largest valid contour and related outputs.Visual outputs show the filtered image and the detected contour drawn on the original image so you can verify results in the UI.
Toggling
Auto threshold ?instantly enables or disables the manualThreshold rangecontrol to let you experiment quickly.
β¨ Features
Visual debugging outputs for both the thresholded image and contour overlay.
Flexible preprocessing: median blur and morphological closing parameters.
Area-based filtering to avoid false contours from noise or borders.
Produces both visual outputs and numeric descriptors (size, position, rotation) for downstream logic or logging.
π Usage instructions
Feed a color image into the
Imageinput socket.Start with moderate
Blur coefficientand a smallClear spots parameter.Try
Auto threshold ?first. If results are noisy, uncheck and tuneThreshold rangemanually.Adjust
Shape area range %so the desired object falls within the allowed area window.Inspect
Filtered ImageandContoured Imageto confirm detection. Use downstream blocks to act onShape PositionorShape Rotation.
π‘ Tips and Tricks
If the image has color noise or lighting variations, try adding a preprocessing chain before this block with
HSV FilterorAdjust Colorsto improve separation of the object from background.Use
BlurorDenoisingupstream to reduce speckle before thresholding for more stable contours.If you need to analyze only a sub-region, crop first with
Image ROI SelectorImage ROIand feed the cropped image into this block.To convert a noisy color scene into a clearer binary input, combine with
Image Adaptive ThresholdorImage Thresholdbefore this block.For further geometric processing or feature extraction, connect outputs to related shape analysis blocks such as
Approximate Contour,Minimum Rectangle,Minimum Rotated RectangleorTranslate Shape.Visualize results live using the
Show Imageblock and save examples or logs withImage LoggerorImage Writefor later inspection.
π οΈ Troubleshooting
No contour found: increase the upper bound of
Shape area range %or lower the minimum; checkFiltered Imageto confirm the object appears after thresholding.Too many small contours: increase
Clear spots parameter(morphological closing) or tighten the minimum area inShape area range %.Object split into multiple contours: reduce blur or decrease morphological closing, or crop region with
Image ROI Selectto isolate the object.Threshold not working: try enabling
Auto threshold ?to let the block pick a suitable threshold automatically, then fine-tune the manualThreshold rangeif needed.
Last updated
Was this helpful?