Hi,
Does anyone know any good resources on how someone can make polygons out of images?
I am a complete noob at anything to do with spatials or polygons, and would like some tips and guidance if anyone has anything to offer.
How could one go about making a polygon from the spidey image below, for example? Is this even possible?
Thanks in advance!
Seffana
Solved! Go to Solution.
Hi @Seffana_ ,
I am afraid you need some image processing algorithm for that purpose. Are you comfortable with python?
You need first to use some libraries to extract some features of your image (OpenCV is a good starting point): https://www.pyimagesearch.com/2016/02/08/opencv-shape-detection/
After, you will need to convert your new image in shapefile but nothing out of the box I think.
You project is not an easy one...
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
I assume you want a way to analyse images?
Have a look at this post:
Hey @Seffana_,
The TL;DR is that you cannot with PNGs or JPEGs but might be able to get some semblance of the original image if you use SVGs.
A JPEG or PNG gives the color values pixel by pixel so it's near impossible to get any polyline or polygon information from them - you could use some form of edge detection but that would be beyond me and probably more trouble than it's worth. An SVG, however, is a vector graphic that contains the path information in the file.
Here's an example of an SVG (original on the left and simplified using graphics software on the right just to get the edge information)
If you open up the SVG in a text editor you can see the path information (which has all the coordinates) is in the form of XML.
Since the SVG is XML you can input the spiderman.svg file into a workflow as XML then parse out the coordinates, create points and create a polyline,
What I haven't solved for is that SVG path is often represented as a Bezier curve and I'm only able to create straight lines from point to point. Maybe one day I'll learn to interpolate the points so Spiderman doesn't look so angular.
I tried converting your image to an SVG (there are some free tools on the internet that do this) but the results weren't pretty.
Hope any of this helps.
P
This is great!
Do you happen to have the svg file with this flow you've created? It's currently not attached in the package.
Hi @AlbertP1, I believe the images in this link is what @PhilipMannering used in his solution workflow.
I would've attached them in this comment but .svg files aren't supported, annoyingly.