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

8 vues (au cours des 30 derniers jours)
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 commentaire
Walter Roberson
Walter Roberson le 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.

Connectez-vous pour commenter.

Réponses (1)

Deep
Deep le 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).

Produits


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by