How can I change paths of my image to polygons?

Post questions on how to use or achieve an effect in Inkscape.
pepino
Posts: 3
Joined: Wed Jun 08, 2011 10:03 pm

How can I change paths of my image to polygons?

Postby pepino » Thu Jun 09, 2011 4:52 pm

Hello Guys!

I need help with converting a image what is made of paths to a image what is made of polygons.
I need that for getting these data ready for a CNC machine.

I hope you guys can help me! :mrgreen:

Best regards,
pepino

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: How can I change paths of my image to polygons?

Postby brynn » Fri Jun 10, 2011 4:25 am

Image
Welcome pepino!

I don't think this is possible. Although I'm not entirely sure what you mean. Inkscape commonly can take its rectangles, ellipses, stars, polygons, and spirals, and convert them to paths. But not the other way around, to my knowledge. Hhhm....well possibly there's an extension??

Ok, there are a couple of extensions that might be helpful, depending on your situation. If the paths have curves, and you want to make them straight, you could use either a) the Flatten Beziers extension, which with a Flatness value of 60.0 will turn an ellipse into a diamond shape, or b) the Straighten Segments extension, which with a Percent value of 100.0 will do the same thing. But in either case, the results are still paths. They are polygons by definition, but still paths.

If this doesn't answer your question, maybe you could show us a screenshot of the original paths. I did look up CNC machine, since I wasn't sure. But apparently CNC can apply to different technologies, so even having the definition, I couldn't guess your application. But a screenshot would clear it all up! :D

User avatar
druban
Posts: 1917
Joined: Fri Nov 20, 2009 10:48 pm

Re: How can I change paths of my image to polygons?

Postby druban » Fri Jun 10, 2011 8:12 am

Hi Pepino if you want to convert several unconnected linear paths to make a single polygon the steps are these:
1. Select all these pathswith the :tool_selector:
2. switch to :tool_node: This shows the all nodes but you need to do ctrl-a to select them all.
3. In the tool control bar click on join nodes - that's the third button. (See picture). Your Inkscape version has to be pretty current for this to work, BTW.
Now you have a single polygon where you had separate lines before.

bitmap.png
bitmap.png (89.68 KiB) Viewed 8727 times


Note that in the above picture I deliberately used lines whose ends do not match up to show that they are separate lines! Because of this the resulting polygon is not exactly the same since Inkscape averages the position of the nodes to arrive at the joined node's position. If your lines have their ends lined up on top of each other, your output polygon will be precisely the same as your input.
Your mind is what you think it is.

pepino
Posts: 3
Joined: Wed Jun 08, 2011 10:03 pm

Re: How can I change paths of my image to polygons?

Postby pepino » Fri Jun 10, 2011 7:18 pm

Thanks for your answers and help.

Well I think this is quite unfortunate to convert my picture to polygons. Since it must be really much of them to get this form.

As attachment you can see my paths, which I need to convert to polygons.

I hope that I still have a chance to do that.

Best regards,
pepino

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: How can I change paths of my image to polygons?

Postby brynn » Sun Jun 12, 2011 2:46 am

Did you forget to upload the attachment?

pepino
Posts: 3
Joined: Wed Jun 08, 2011 10:03 pm

Re: How can I change paths of my image to polygons?

Postby pepino » Wed Jun 15, 2011 6:05 pm

Yea I forgot the file. Couldnt change it, because I just can make one Post via Day??

I hope this picture helps.
Attachments
path2poly.jpg
path2poly.jpg (189.58 KiB) Viewed 8643 times

User avatar
druban
Posts: 1917
Joined: Fri Nov 20, 2009 10:48 pm

Re: How can I change paths of my image to polygons?

Postby druban » Wed Jun 15, 2011 6:14 pm

Sorry Pepino, your image does not by itself explain what it is you are trying to do, although I am sure it seems obvious to you.
at a guess, i would say you need to explain in more detail and possibly upload the file as well.
Do you want the white areas to become shapes ("polygons"??) You want all the curves to be converted to straight line segments?

Maybe this will work for you:
1. select all.
2. Path menu > union.
3. Path menu> break apart.
4. Select outermost (biggest) shape and delete.
This will convert all the white areas - "holes" into separate paths.
It is to be hoped that this will give you what you want.
Your mind is what you think it is.

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: How can I change paths of my image to polygons?

Postby brynn » Thu Jun 16, 2011 9:04 am

Hi pepino and druban,
I might be having a slightly different interpretation. But before I start with suggestions, I just want to make sure that the image is in SVG format. I see the file you uploaded is a JPG, and I understand that you may have converted, or used a converted copy to upload (or something like that). But it would need to be in SVG format for editing in Inkscape. (It can be converted in Inkscape, if necessary, and maybe you've already done that? Anyway, just to be sure.)

Now seeing your image, I'm thinking the Flatten Beziers extension that I mentioned earlier, might be the answer. (again assuming it's an SVG and that I understand what you want to do, lol)

PS - I'll attempt to convert and test

EDIT
2nd PS - You may post as many messages per day as you wish (as long as they aren't spam, lol). But I do sometimes get an error that says something like 'you're not allowed to post again so soon'. I'm not sure what the amount of time is, between messages, but I think it's like 1 to 3 minutes. Anyway, if you get that error message, just wait a few more minutes, and you should be able to post as expected :D
Last edited by brynn on Thu Jun 16, 2011 9:08 am, edited 1 time in total.
Reason: add extra comment

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: How can I change paths of my image to polygons?

Postby brynn » Thu Jun 16, 2011 9:38 am

Ok, this is what Flatten Beziers does to your image (I used Trace Bitmap to convert, so yours would be slightly different). Is this kind of what you want, or do you want separate polygons that are not connected to each other? Or even something else?

pepino1.PNG
pepino1.PNG (66.45 KiB) Viewed 8609 times


To get more well defined polygons, I did Path > Simplify on the original, to reduce the number of nodes, before using Flatten Beziers. Here's that result:

pepino2.PNG
pepino2.PNG (53.2 KiB) Viewed 8609 times

User avatar
druban
Posts: 1917
Joined: Fri Nov 20, 2009 10:48 pm

Re: How can I change paths of my image to polygons?

Postby druban » Thu Jun 16, 2011 10:55 am

Good point, Brynn. I think these two interpretations should really cover the needs of our poster...
Your mind is what you think it is.

User avatar
BobSongs
Posts: 324
Joined: Fri Sep 14, 2007 2:18 pm
Location: Montreal, Canada

Re: How can I change paths of my image to polygons?

Postby BobSongs » Thu Jun 16, 2011 12:21 pm

druban wrote:Hi Pepino if you want to convert several unconnected linear paths to make a single polygon the steps are these:
1. Select all these pathswith the :tool_selector:
2. switch to :tool_node: This shows the all nodes but you need to do ctrl-a to select them all.
3. In the tool control bar click on join nodes - that's the third button. (See picture). Your Inkscape version has to be pretty current for this to work, BTW.
Now you have a single polygon where you had separate lines before.
Druban:

I've followed your steps in that:

1. I created 5 lines, each had a single node at the end of each line.
2. placed the nodes fairly close to where I wanted them to connect, similar to your diagram.
3. selected :tool_selector: all lines (Ctrl A works too)
4. switched to the node editor :tool_node:
5. clicked the 3rd icon from the left (Join Selected Nodes)
6. Nothing happened.

Inkscape version: 0.48.1, compiled from source with all dependencies met.
OS = Ubuntu Linux, 10.10

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: How can I change paths of my image to polygons?

Postby brynn » Thu Jun 16, 2011 1:50 pm

Bob, the Ctrl A should be done after switching to the Node tool.

User avatar
druban
Posts: 1917
Joined: Fri Nov 20, 2009 10:48 pm

Re: How can I change paths of my image to polygons?

Postby druban » Thu Jun 16, 2011 7:15 pm

As Brynn points out, the nodes are not selected until the :tool_node: selects them. There is a subtle and very well designed interaction of the :tool_selector: and the :tool_node:. You can use the :tool_selector: to select several paths and hand them off to the :tool_node: for editing.
Recent versions of the :tool_node: allow you to add paths to this selection or start from scratch and select each path to be edited by shift clicking but at the end none of the nodes are highlighted and you must select all using ctrl-a (as in the case being discussed here ) or draw a marquee with the node tool (note that while drawing the marquee rectangle you can draw over paths and nodes that were not selected before and their nodes will not be selected!) or shift click each node. There's a lot of very sensitive coding here - if the :tool_node: is activated without any paths selected, then you can use the marquee rectangle to select paths, but if some paths are already selected, then the marquee switches to only seeing nodes of selected paths - very useful once you get the hang of it. Try using the esc key or clicking away from the selected nodes to see more cool behaviour of the :tool_node: - if you esc or click on the canvas, with nodes selected it deselects the nodes but leaves the paths selected, do it again and it deselects the paths as well...
Your mind is what you think it is.

User avatar
BobSongs
Posts: 324
Joined: Fri Sep 14, 2007 2:18 pm
Location: Montreal, Canada

Re: How can I change paths of my image to polygons?

Postby BobSongs » Fri Jun 17, 2011 4:26 pm

Well, this is what I've discovered so far.

1. I've drawn a number of lines.
2. I'm not switching to the :tool_selector: at all, okay?
3. If, once I've drawn the last line, I use :tool_node: to select all lines, I can only select the last line drawn.
4. So, I must use :tool_node: to click the white space until no lines are selected.
5. Once all lines are unselected the :tool_node: lets me select all lines when I draw a bounding box around them.
6. Now that :tool_node: is selected I click the 3rd button in the toolbar.
7. Absolutely nothing happens to my lines. No node joining, nothing.
8. To join the nodes I've had to select two nodes from non-joining lines, highlight the ends of each line, then click the 3rd button.
9. This is when the lines begin to join.

User avatar
druban
Posts: 1917
Joined: Fri Nov 20, 2009 10:48 pm

Re: How can I change paths of my image to polygons?

Postby druban » Sat Jun 18, 2011 7:13 am

BobSongs wrote:Well, this is what I've discovered so far.

1. I've drawn a number of lines.
2. I'm not switching to the :tool_selector: at all, okay?
3. If, once I've drawn the last line, I use :tool_node: to select all lines, I can only select the last line drawn.
4. So, I must use :tool_node: to click the white space until no lines are selected.
5. Once all lines are unselected the :tool_node: lets me select all lines when I draw a bounding box around them.
6. Now that :tool_node: is selected I click the 3rd button in the toolbar.


Not yet, as Brynn and I have pointed out, selecting the lines is not the same as selecting the nodes of the lines. Before you click the join nodes button you must either type ctrl-a or draw another marquee around the nodes you want joined. They should change color to the highlight color (blue). Only then have you given the :tool_node: something to join.
Your mind is what you think it is.

User avatar
BobSongs
Posts: 324
Joined: Fri Sep 14, 2007 2:18 pm
Location: Montreal, Canada

Re: How can I change paths of my image to polygons?

Postby BobSongs » Sun Jun 19, 2011 1:44 am

druban wrote:
BobSongs wrote:Well, this is what I've discovered so far.

1. I've drawn a number of lines.
2. I'm not switching to the :tool_selector: at all, okay?
3. If, once I've drawn the last line, I use :tool_node: to select all lines, I can only select the last line drawn.
4. So, I must use :tool_node: to click the white space until no lines are selected.
5. Once all lines are unselected the :tool_node: lets me select all lines when I draw a bounding box around them.
6. Now that :tool_node: is selected I click the 3rd button in the toolbar.


Not yet, as Brynn and I have pointed out, selecting the lines is not the same as selecting the nodes of the lines. Before you click the join nodes button you must either type ctrl-a or draw another marquee around the nodes you want joined. They should change color to the highlight color (blue). Only then have you given the :tool_node: something to join.

Ahh, so I select all the lines with :tool_node: twice.

Interesting! Not my first impression of how this would be done... but, I gave it a test run and it worked.

That's such an odd concept though. Still, glad it functions. I'd given up hope that I could ever get this feature to work.


Return to “Help with using Inkscape”