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

  1. Provide a suitable grayscale image to Input Image (Grayscale) for visualization.

  2. Feed the contour or point list you want to check into Test Shape.

  3. Feed the enclosing contour into Enclosing Shape.

  4. Read the annotated image from Output Image and the inclusion result from Plot Image.

πŸ’‘ Tips and Tricks

  • Use Find Contour to extract contours from a binary image and connect its result to Enclosing Shape or Test Shape.

  • Use Approximate Contour to simplify complex contours before testing to speed up evaluation and reduce false negatives.

  • Crop the region of interest first with Image ROI or Image ROI Select to focus the test on relevant areas and reduce processing.

  • To inspect or create the shape to test, use Contour to Image or draw points with Draw Point and then use that output as the Test Shape.

  • If the test shape should be derived from segmentation, try Image Threshold or Fill Contour beforehand 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 Image to confirm shapes are fed correctly.

  • If contour extraction fails to provide usable shapes, preprocess the image with Blur or Image Threshold for better edge detection.

Last updated

Was this helpful?