Most Similar Shape
This function block compares a reference contour against a list of candidate contours and selects the most similar one. It returns the best-matching contour, a similarity score (0-1), and an annotated image showing the selected contour.
π₯ Inputs
ContourReference contour used for comparisonContour(s)List of candidate contours to compare againstImageOptional image used for visual output/annotation
π€ Outputs
Most SimilarThe contour from the candidate list that best matches the referenceScore (0-1)Similarity score (1.0 means identical, lower values indicate less similarity)Image AnyOptional annotated image with the selected contour highlighted
πΉοΈ Controls
This function block has no user-configurable controls. It runs automatically when inputs are provided.
π¨ Features
Fast comparison of shapes to find the closest match in a list.
Produces both a numeric similarity score and a visual result for verification.
Works with any contour format accepted by the system.
π Usage Instructions
Provide a reference contour to
Contourinput.Provide one or more candidate contours to
Contour(s)input.Optionally supply an image to
Imageto receive an annotated visual showing which contour was chosen.Run the scenario; outputs will include the selected contour, its similarity score, and the annotated image if supplied.
π Evaluation
When evaluated, this block measures resemblance between the reference contour and each candidate. It returns the candidate with the best resemblance (highest similarity) along with a numeric score and an annotated image (if provided).
π‘ Tips and Tricks
To extract contours from a binary image first, use
Find Contourto get contours suitable for comparison.Use
Approximate Contourto simplify contours (reduce point count) before comparison when shapes are noisy or overly detailed.Combine with
Hull Convexto compare convex hulls instead of raw contours when outer shape similarity is desired.Use
Minimum Rectangle,Minimum Ellipse, orMinimum Circleto convert contours into simple geometric descriptors for alternate comparison strategies.Preprocess input images with
Blur,Denoising, orImage Thresholdto reduce noise and improve contour extraction.If you want to visually inspect the selected result, connect the annotated image output to
Show Image.Use
Contour to Imageto crop or isolate the region around a contour for further inspection or downstream processing.Draw the selected contour on live output using
Draw Result On ImageorDraw Detectionsfor clearer visualization in dashboards.If you only need to compare contours within a sub-area, crop first with
Image ROIorImage ROI Selectto limit candidates and speed up processing.For batch comparisons over multiple regions, use
Image ROI PolygonorImage ROI Polygon Multito generate multiple areas and feed their contours into this block.
π οΈ Troubleshooting
If similarity scores are unexpectedly low, ensure contours are extracted from a clean binary image (use
Image ThresholdandBluras needed).If multiple candidates produce similar scores, simplify contours with
Approximate Contouror compare bounding shapes (Minimum Rectangle,Minimum Ellipse) to reduce sensitivity to small differences.If the visual output does not show the selected contour, verify an image was provided to the
Imageinput or connect the block output toShow Imagefor preview.
Last updated
Was this helpful?