community
cancel
Showing results for 
Search instead for 
Did you mean: 

Alteryx designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.
SOLVED

How to make a polygon from images?

Highlighted
Alteryx Partner

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?

 

spiderman.jpg

 

Thanks in advance!

 

Seffana

Alteryx
Alteryx

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.

 

Alteryx
Alteryx

@Seffana 

 

I assume you want a way to analyse images?

 

Have a look at this post:

https://community.alteryx.com/t5/Alteryx-Designer-Discussions/Images-analysis-is-possible-in-alteryx...

Alteryx Certified Partner

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)

spiderman.pngSVGspiderman-outline.svgSVG outline

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.

Example SVG.jpgSVG 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,

Workflow.jpgWorkflow

 

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

 

 

 

Alteryx Partner

Hi @PhilipMannering,

 

Thank you so much! The detailed explanation was really helpful!

Labels