fablabnbg / inkscape-centerline-trace

A bitmap vectorizer that can trace along the centerline of a stroke. The builtin inkscape 'trace bitmap' can only trace edges, thus resulting in double lines for most basic use cases. It uses 'autotrace -centerline' and an optimal threshold to vectorize a pixel image.
https://github.com/fablabnbg/inkscape-centerline-trace/releases
GNU General Public License v2.0
244 stars 33 forks source link

Trace result only consists of a straight two-node line, stroke width 0 #3

Closed Moini closed 8 years ago

Moini commented 8 years ago

The png file is being created, and contains an image with black line on transparent background.

The result of the tracing is just a two-node straight line path with a stroke width of 0.0.

What may be wrong?

Danke!

Info section: Using the extension (the version with my fixes from the pull request at https://github.com/fablabnbg/inkscape-centerline-trace/pull/2) from either the Inkscape command line (inkscape /tmp/Zeichnung.svg --select=image6708 --verb=com.github.fablabnbg.inskscape-centerline-trace.noprefs) or directly from inside the program, with the attached file (had to rename to .txt for github to consider uploading it...) in Inkscape 0.91 on Linux Mint 17.3 (based on Ubuntu 14.04).

Debug output from commandline: inkscape /tmp/Zeichnung.svg --select=image6708 --verb=com.github.fablabnbg.inskscape-centerline-trace.noprefs init id=image6708 tag={http://www.w3.org/2000/svg}image embedded image: data:image/png;base64, filename=/tmp/tmp15HLq7.png im_width 277 sx= 1.0 im_height 385 sy= 1.0 im_x 223.86423 im_y 70.162651 pixel_size= (277, 385)

Debug output inside Inkscape: svg_centerline_trace start /tmp/tmp15HLq7.png seen: [None, (277, 385), 'L'] attempt 0 bw from lut done pbm from bw done autotrace done attempt 1 bw from lut done pbm from bw done autotrace done attempt 2 bw from lut done pbm from bw done autotrace done attempt 3 bw from lut done pbm from bw done autotrace done attempt 4 bw from lut done pbm from bw done autotrace done best: 2/5

centerline_result centerline_settings Zeichnung.txt

Moini commented 8 years ago

Answering my own question: The extension has difficulties with black on transparent background.

It does not work with the jpg images that are included in the test data files, btw. - making a bitmap copy of the embedded jpg works, though, as that creates an embedded png.

jnweiger commented 8 years ago

Transpacency is ignored by autotrace and the 'original color' that was there, before you made it transparent applies. That is bad, but I have no good solution, since a transparent area should in my understanding contrast nicely with both black and white and any other color. That is something autotrace cannot do. At best, we could detect transparency and show a warning.

We digged into the issue with embedded jpegs yesterday night. Followup here: https://github.com/fablabnbg/inkscape-centerline-trace/issues/8

Moini commented 8 years ago

At best, we could detect transparency and show a warning.

Or we could just assume the contrasting background is white, and use imagemagick or PIL to put a white bg behind before tracing (won't work in all cases, I know - but in most, and users already need im/PIL for many other extensions, they're no exotic dependencies).

Thanks for the jpg work and the merge :D

jnweiger commented 8 years ago

PIL is already a dependency, used for normalizing contrast and scaling down.

jnweiger commented 8 years ago

Please check out https://github.com/fablabnbg/inkscape-centerline-trace/releases/tag/v0.6

Moini commented 8 years ago

Hey, cool :) Thanks! That'll save people some confusion.

I think the README still needs an update, now. I just noticed that there is the option to trace bright lines - didn't remember that it existed...
That could be used to determine if a black or white bg should be added.

I'll do those two updates, you can decide if you'd like to merge.

Moini commented 8 years ago

see https://github.com/fablabnbg/inkscape-centerline-trace/pull/9