Using [`FindClusters`](http://reference.wolfram.com/language/ref/FindClusters.html) to group the pixels coord = FindClusters[ImageValuePositions[imagem, Red], 5]; coord = Table[Mean[coord[[i]]], {i, 1, 5}] ListPlot[coord] > {{36., 204.}, {347., 184.}, {150., 149.}, {246., 76.}, {71., 39.}} [![enter image description here][1]][1] Show[ imagem, Graphics@Line@Subsets[#, {2}] &@coord] [![enter image description here][2]][2] [1]: https://i.sstatic.net/pU1kr.png [2]: https://i.sstatic.net/DXskw.png