Point Polygon Test
This function block checks whether a test shape (contour/points) is located inside another enclosing shape. It annotates the input image with visual markers and returns a boolean indicating whether all test points are inside the enclosing contour.
π₯ Inputs
Input Image (Grayscale) A grayscale image used as background for visualization and drawing.
Test Shape A shape (contour or list of points) to be tested for inclusion.
Enclosing Shape A contour that acts as the reference enclosure.
π€ Outputs
Output Image An annotated image showing the test points and the enclosing contour. Points inside are marked in one color, points outside in another.
Plot Image A boolean result: True if all test points lie inside the enclosing contour, otherwise False.
πΉοΈ Controls
This block has no additional interactive controls. It runs based on the provided inputs.
π¨ Features
Visual annotation of the reference contour and each test point on the image for easy verification.
Per-point indication (inside vs outside) using color-coded markers.
Returns a single boolean summarizing whether the test shape is fully enclosed.
βοΈ Running mechanism
When executed, the block reads the three sockets listed under inputs.
If either shape input is empty, the block returns the input image unchanged and does not perform the test.
If both shapes are provided, the block draws the enclosing contour and evaluates each point of the test shape against the enclosure.
Each test point is drawn on the image with a color indicating inside or outside. The boolean output reflects whether all test points are inside.
π Usage instructions
Provide a suitable grayscale image to
Input Image (Grayscale)for visualization.Feed the contour or point list you want to check into
Test Shape.Feed the enclosing contour into
Enclosing Shape.Read the annotated image from
Output Imageand the inclusion result fromPlot Image.
π‘ Tips and Tricks
Use
Find Contourto extract contours from a binary image and connect its result toEnclosing ShapeorTest Shape.Use
Approximate Contourto simplify complex contours before testing to speed up evaluation and reduce false negatives.Crop the region of interest first with
Image ROIorImage ROI Selectto focus the test on relevant areas and reduce processing.To inspect or create the shape to test, use
Contour to Imageor draw points withDraw Pointand then use that output as theTest Shape.If the test shape should be derived from segmentation, try
Image ThresholdorFill Contourbeforehand to create clean contours for more reliable results.
π οΈ Troubleshooting
If all points report outside unexpectedly, verify that the coordinate systems match (cropping or resizing upstream can shift coordinates).
If the result is inconclusive, visualize intermediate contours using
Show Imageto confirm shapes are fed correctly.If contour extraction fails to provide usable shapes, preprocess the image with
BlurorImage Thresholdfor better edge detection.
Last updated
Was this helpful?