I have an Image (PNG) with simple polygons of different colours. I need to serialise these polygons given that the top left corner have the coordinates [0,0]. I already tried gdal_polygonize and I am almost happy with the result but there is one problem. Take a look at this triangle I would like to get the corner points and their sequence to know which of them are linked together. So the coordinates I expect are [30.0, 23.0 ], [ 30.0, 504.0 ], [ 511.0, 504.0 ], [ 30.0, 23.0 ]. I tried gdal_polygonize.py but when I try
gdal_polygonize -8 triangle.png triangle
I get hundreds of coordinates because it counts every single pixel of the hypotenuse as a corner of the polygon. What can I do? There must be some algorithms for it but all I can find are algorithms to extract polygons from 3d objects and so on :(
I am not sure but maybe this is the solution for my problem but since I am not so good in R I would like to know, whether I can use an R-script and if so how does it have to look like?