Distinguish incomplete and complete triangles from a given image and display their respective numbers
11 views (last 30 days)
Show older comments
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 Comment
Walter Roberson
on 14 Jan 2025
You have a bit of a problem in that your images are JPEG, and by default JPEG blurs sharp edges. If possible, avoid storing the images as JPEG.
Answers (1)
Deep
on 14 Jan 2025
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).
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!