Turn shapes into single lines?

Post questions on how to use or achieve an effect in Inkscape.
DavidBrennan
Posts: 41
Joined: Thu Jan 19, 2012 10:33 pm

Turn shapes into single lines?

Postby DavidBrennan » Wed Apr 04, 2012 6:13 pm

Does anybody know of any automatic (or else quick and easy) techniques for turning bitmaps which are composed of line-type images into single lines using Inkscape?

For instance, I scanned my signature. Then, in Inkscape I used the paint bucket the select the bitmap and turn it into a .SVG. As you can guess, though, this new SVG of the signature was composed of a tracing of its perimeter. What I would like would be just a single line which I could then visualize with its Stroke rather than any Fill. (Ultimately, I solved this by simply tracing it manually with Inkscape's pen tool. However, this would obviously take a long, long time if a whole page of words were converted in this manner!)

I was also attempting to achieve it with this graphic of a face mesh, because the paint bucket method resulted in a very, complex series of curves (and it just wasn't as precise as having single lines through the mesh).

Image

DavidBrennan
Posts: 41
Joined: Thu Jan 19, 2012 10:33 pm

Re: Turn shapes into single lines?

Postby DavidBrennan » Thu Apr 05, 2012 2:17 am

In case it wasn't clear what I meant, here's another illustration of what I mean.

Image

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

Re: Turn shapes into single lines?

Postby brynn » Thu Apr 05, 2012 2:44 pm

I think you might be able to accomplish it with a Centerline trace. Inkscape's Trace Bitmap does not offer this feature, but this one does: http://www.roitsystems.com/cgi-bin/autotrace/tracer.pl Note that I'm not absolutely positive that a centerline trace makes a single path. But I think it might.

I don't know of any way to convert something that's already been traced.

DavidBrennan
Posts: 41
Joined: Thu Jan 19, 2012 10:33 pm

Re: Turn shapes into single lines?

Postby DavidBrennan » Thu Apr 05, 2012 5:13 pm

Thanks for the tip there, Brynn. I went to that site and couldn't really get any good results, but I only tried twice.

I would guess that many users would put a feature like this to great use on Inkscape in many situations, but especially for handwriting graphics and animations (animated when imported into Blender).

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

Re: Turn shapes into single lines?

Postby brynn » Thu Apr 05, 2012 8:44 pm

Well yes, I certainly can see the potential benefits. But we're talking about converting more than "just" image formats. In this case we're converting raster (bitmap) to vector, and in some....well, many ways, it seems to me that we're lucky to be able to do it at all. I'd be hard pressed to think of even a long way to do it.

I am curious though, about the centerline trace. I'll give it a try, and let you know what I learn.

Edit
Yes, the Centerline Trace option did result in a single stroked path for a single line, rather than a filled shape! I did not use a signature to test it, just a simple line drawing. Hhmm....ok, I'll try a signature....well I'll have to just use a squiggly stroked path, because I can't really write with a mouse.

Aahhh, well it didn't turn out as I expected. It does indeed result in a single path. But there are many paths, when the original was one single path. I'm not sure why it breaks it up like it does. The Centerline option is intended to be used for text/font, so maybe that has something to do with it. I can think of some fonts though which could be adversely affected. Or maybe it has something to do with the thickness of the original line. I made the original stroke width 5.00, just for clarity. Maybe a narrower line would work better? But anyway, here's the before and after:

<<<<---- before on left /// after on right ---->>>>

Image Image

So I don't think a signature will turn out looking right. It may be that your Spiderman example would work better, since the lines are more right-anglish. But it would just take a couple of seconds to try it :D

Well, I couldn't resist, lol. I tried a path of 1.0 width, and it does result in less distortion. But it's still several paths, broken in seemingly illogical places. However, there are a number of variables that can be adjusted. I did not play around with those, but I suspect you could get something closer to acceptable, once you find the right ones. I just don't have the time to experiment. Good luck :D

DavidBrennan
Posts: 41
Joined: Thu Jan 19, 2012 10:33 pm

Re: Turn shapes into single lines?

Postby DavidBrennan » Thu Apr 05, 2012 8:52 pm

Thanks, Brynn. I can't do any programming (though I hope to learn one day) but I would guess that there are several different methods of achieving something like this.

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

Re: Turn shapes into single lines?

Postby brynn » Thu Apr 05, 2012 9:42 pm

Oops, sorry. You replied while I was editing my last message. Just didn't want you to miss it. I think if you adjust those variables, you might get something pretty close. I just don't have time to experiment.

DavidBrennan
Posts: 41
Joined: Thu Jan 19, 2012 10:33 pm

Re: Turn shapes into single lines?

Postby DavidBrennan » Thu Apr 05, 2012 10:11 pm

Well, I've uploaded that face mesh to the site probably six different times, each time with different settings, and I have to say that I'm not getting anything that looks remotely like it. Instead, there are just these weird angular shape results, with no connection that I can tell to the original mesh.

It's not a huge deal. But if that demonstrates proof of concept, it would be awesome if somebody could maybe make an add-on or something to achieve this.

DavidBrennan
Posts: 41
Joined: Thu Jan 19, 2012 10:33 pm

Re: Turn shapes into single lines?

Postby DavidBrennan » Fri Apr 06, 2012 5:46 am

I played with it a little more and figured out my main problem: I had an alpha=0 channel in the .PNG that I was uploading. For some reason, that screws things up. Once I added a white background, I was able to get an OKAY mesh, but, like Brynn noted, it comes in as many different objects and there appear to be other odd artifacts. Still, it's good enough that it demonstrates the viability of the concept, I think.

stNick
Posts: 5
Joined: Sat Apr 07, 2012 8:36 pm

Re: Turn shapes into single lines?

Postby stNick » Tue Apr 10, 2012 12:31 am

Hi David,
have you had any luck getting these single lines for tracing? I'm looking for the same solution as I want to trace sketches and put them in the milling machine. But because a single line of a sketch gets converted into 2 lines the machine will go over that area twice.

I have some programming skills and am willing to fiddle around in code but I don't know in with what (open source) package to start in order to accomplish our common goal.

PS
I know Corel Draw has centerline tracing features that are better than the given website. Maybe that is a solution for you?

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

Re: Turn shapes into single lines?

Postby brynn » Tue Apr 10, 2012 2:38 am

Hhhhm....well, I have thought of a pretty ugly way to do this. I haven't actually tried it yet, but here it is. Do the trace using one of the single scan options. Select the result and do Path menu > Break apart. This will result in 2 paths, the inside and the outside. (Before, it was technically a compound path of 2 subpaths.) Now select both and open Extensions menu > Generate from path > Interpolate. Set Interpolations steps to 1, and Apply. Theoretically, that will give you a single path that is more or less centered between the inside and the outside. Then you could just delete the original paths. I don't know how accurate that will be. I suspect it will make sharp corners acutely rounded. But I guess it couldn't hurt to try :D Or maybe you could tweak the node handles to repair the corners?

You can start here, in the Developers section: http://wiki.inkscape.org/wiki/index.php/Inkscape to learn about the mailing list, and where to find the code and stuff. You should be able to find the irc channel somewhere there in the wiki, if you don't want to join the mailing list. Also, in our Programming subforum, someone has made somewhat of a tutorial, which I think is aimed at making extensions. I don't know if an extension is what you would want for this though. It sounds more like you want to add functionality to the existing Trace Bitmap (potrace). I really wish I could give you some better info, but I'm just not well informed about the development side of Inkscape.

stNick
Posts: 5
Joined: Sat Apr 07, 2012 8:36 pm

Re: Turn shapes into single lines?

Postby stNick » Tue Apr 10, 2012 6:47 pm

I did some digging last night and I found that potrace is just not fit for the job. It's something with the algorithms it uses so that's a no go. Autotrace, which is also implemented in that website you provided, is one of the few libraries that is capable of center lining. That, and CorelDraw below version X3. But for me the software needs to be open source like Autotrace so I'll be looking into the possibilities from there.

DavidBrennan
Posts: 41
Joined: Thu Jan 19, 2012 10:33 pm

Re: Turn shapes into single lines?

Postby DavidBrennan » Wed Apr 11, 2012 3:16 am

Thanks for all the interest and research, guys. Many of us cannot afford commercial software (though there's always Torrent and other ways of getting it when it's absolutely needed), and an in-program solution to this would be wonderful and, I'm sure, used routinely by Inkscape users. The existence of at least two other programs with a similar feature (Autotrace and CorelDraw) demonstrate its technical viability.

So thanks for what you've contributed so far, and if you could go one-step further and somehow make it possible in Inkscape, I believe that would be a big hit. Sorry that I'm no use in this regard.

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

Re: Turn shapes into single lines?

Postby brynn » Thu Apr 12, 2012 4:21 am

I don't know if there's been a new feature request for this or not. You could check Launchpad https://launchpad.net/inkscape. If you register, then once you find it, you can click a button that says "This affects me too" or something like that, and add your support to the request. Or if it doesn't already exist, you could make a new report.

(Note that this is primarily a users' forum, and that most developers don't visit or participate here. Launchpad is the bug tracker, and also where new feature requests are accepted.)

DavidBrennan
Posts: 41
Joined: Thu Jan 19, 2012 10:33 pm

Re: Turn shapes into single lines?

Postby DavidBrennan » Thu Apr 12, 2012 10:28 am

brynn wrote:I don't know if there's been a new feature request for this or not. You could check Launchpad https://launchpad.net/inkscape. If you register, then once you find it, you can click a button that says "This affects me too" or something like that, and add your support to the request. Or if it doesn't already exist, you could make a new report.

(Note that this is primarily a users' forum, and that most developers don't visit or participate here. Launchpad is the bug tracker, and also where new feature requests are accepted.)

Yeah, the only reason I was putting in a "request" here was because stnick seemed to be saying that he was going to give it a shot, and I wanted to encourage that, for sure.

I will put in a request for it within a day. (Although it appears as though Inkscape only rarely updates the software, unlike Blender and GIMP.)

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

Re: Turn shapes into single lines?

Postby brynn » Thu Apr 12, 2012 4:21 pm

Oh sorry, I missed that.
I guess the development rate depends on what you compare Inkscape to. To me, it's moving along quickly :D

DavidBrennan
Posts: 41
Joined: Thu Jan 19, 2012 10:33 pm

Re: Turn shapes into single lines?

Postby DavidBrennan » Thu Apr 12, 2012 4:30 pm

brynn wrote:Oh sorry, I missed that.
I guess the development rate depends on what you compare Inkscape to. To me, it's moving along quickly :D

I don't follow it closely at all. In fact, I've just been learning the program intermittently over the past three or four months, so I'm a novice all-around. But I can say that Blender and GIMP seem to have updates at least monthly, and there is always talk of this-or-that major upgrade. But, based upon what I know (which isn't too much, admittedly), there doesn't seem to be a comparable amount of new activity on Inkscape.

Looking at the Wikipedia page, there hasn't been a new version since 2010 (not counting bug fixes).

I'm not really complaining, since I couldn't do any of that. But I get spoiled by GIMP and Blender (especially Blender!) and so, ya know, by comparison Inkscape isn't as regularly novel. (I also think that adding animation ability would be HUGE and I don't think there's much work on that?)

Please don't interpret any of this to be a fundamental non-appreciation or anything. I'm hugely grateful for the program and have had a good time learning it, and it's come in handy on many occasions, already.

DavidBrennan
Posts: 41
Joined: Thu Jan 19, 2012 10:33 pm

Re: Turn shapes into single lines?

Postby DavidBrennan » Thu Apr 12, 2012 4:48 pm

Brynn,

I just posted the request (I think) at Inkscape's Launchpad page. I posted it in the "Question" section, as that's apparently where new feature requests are supposed to go.

Here is a link: https://answers.launchpad.net/inkscape/+question/193395

Thanks.

romani.shenuda
Posts: 1
Joined: Tue Jan 19, 2016 3:08 am

Re: Turn shapes into single lines?

Postby romani.shenuda » Tue Jan 19, 2016 3:19 am

http://online.rapidresizer.com/tracer.php

U will love this one
BTW
try both options: no smooth and smooth. the first option usually work good

mrkam
Posts: 1
Joined: Sat Sep 03, 2016 11:17 am

Re: Turn shapes into single lines?

Postby mrkam » Sat Sep 03, 2016 11:18 am

romani.shenuda wrote:http://online.rapidresizer.com/tracer.php

U will love this one
BTW
try both options: no smooth and smooth. the first option usually work good

Cool! Exactly what I was looking for!

KingHelps
Posts: 1
Joined: Thu Sep 06, 2018 9:26 pm

Re: Turn shapes into single lines?

Postby KingHelps » Thu Sep 06, 2018 9:39 pm

As brynn pointed out, Path -> Break Apart can be used (but I missed it when scanning over this page!).

Path -> Trace Bitmap
Select path
Path -> Break Apart
Turn off Fill, turn on Stroke (with thin width)
Delete unwanted duplicate lines.

For the face image shown, you could make the big outside shape Fill 0 0 0, and the inside window shapes fill 255 255 255.

Cheers.


Return to “Help with using Inkscape”