Distinguish incomplete and complete triangles from a given image and display their respective numbers

4 次查看(过去 30 天)
I have a smoothed edge image and would like to highlight with 2 different colors (green - complete triangle, red - incomplete traingle) and display their respective count (how many incomplete triangles and how many complete triangles). I have attached image for reference.

回答(1 个)

colordepth
colordepth 2025-1-14
You can start by identifying all polygons through the calculation of connected components. This can be achieved using the "bwconncomp" function (https://www.mathworks.com/help/images/ref/bwconncomp.html).
Once you have separated the polygons, you can apply corner detection methods to count the number of corners in each polygon. The Harris corner detector method (https://www.mathworks.com/help/vision/ref/detectharrisfeatures.html) is one option. Alternatively, you can use Shi and Tomasi's minimum eigenvalue method (https://www.mathworks.com/help/vision/ref/detectmineigenfeatures.html). A complete triangle can be identified as any polygon with exactly three corners.
In your images, there may be some edge cases where the polygons are cut off by the border of the image. You can filter out these figures by checking their cyclicity using a traversal algorithm, like depth-first search, ensuring that only fully enclosed polygons are considered for corner counting.
To access the documentation for these functions in MATLAB R2018a, you can use the "doc" command (https://www.mathworks.com/help/matlab/ref/doc.html).

产品


版本

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by