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

11 visualizaciones (últimos 30 días)
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 comentario
Walter Roberson
Walter Roberson el 14 de En. de 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.

Iniciar sesión para comentar.

Respuestas (1)

Deep
Deep el 14 de En. de 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).

Productos


Versión

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by