gotcha

Author Topic: Any idea why Visio does not correctly display paths generated by Trace Bitmap?  (Read 4147 times)

September 13, 2017, 10:16:13 AM
Read 4147 times

TransientVagabond

  • Sr. Newbie

  • Offline
  • **

  • 8
I'm using Trace Bitmap to generate black and white line drawings. Trace Bitmap outputs a single compound path with black fill. If I break apart the compound path, I get all the component paths, but each component path gets the fill of the compound path. What I would like to do is apply the black fill to the appropriate component paths so that the result looks the same as the compound path.

I hope that makes sense.

I modified an extension to do this based on how the component paths overlap. However, that extension used bounding boxes to detect overlap, which only works in cases where the paths are squarish.

Any help or direction would be greatly appreciated.
  • 0.92
  • Windows 10

September 13, 2017, 10:38:27 AM
Reply #1

TransientVagabond

  • Sr. Newbie

  • Offline
  • **

  • 8
I've attached an SVG file SEADOO.svg
*SEADOO.svg
(430.49 kB . 327x222)
(viewed 697 times)
containing an example path and a PNG file SEADOO.png
*SEADOO.png
(149.43 kB . 2133x978)
(viewed 743 times)
showing how Visio displays it.
  • 0.92
  • Windows 10

September 13, 2017, 03:34:44 PM
Reply #2

Moini

  • IC Mentor

  • Offline
  • ******

  • 1,568
    • VektorRascheln
Trace bitmap is generally rather unsuitable for line drawings (see https://github.com/fablabnbg/inkscape-centerline-trace for another option that works well on Linux, cannot be installed anymore on macOS, and seems difficult to install on Windows).

Have you checked the other options for trace bitmap in the dialog? E.g. it looks like you want the result to have two colors, so perhaps you want to trace in two colors, not stacked?

September 13, 2017, 03:52:22 PM
Reply #3

brynn

  • Administrator

  • Offline
  • ******

  • 3,941
  • Gender
    Female

    Female
    • Inkscape Community
Welcome to the forum!

Interesting, I didn't realize Visio is a vector graphics program.  Wikipedia says it's a "diagramming and vector graphics program".  But when I look at it's website, it looks more like a high end tv.  Hhmm.....I think these are entirely separate products.  Ah yes -- the MS product.

Well anyway.  I don't think the problem is related to Trace Bitmap.....well, maybe indirectly, but not a causitive factor.

I'm suspecting the problem lies with Visio, in this case.  The reason I think that is because I don't see any problems with the SVG file.  I do notice that it contains 27,255 nodes.  And I know lot of viewers and other programs have trouble handling such a large amount of nodes.

Is the SVG file you provided here the exact same file which Visio is having trouble with (or a copy of it)?  Have you tried viewing other SVG files with Visio?  It would make a good test if you could find another SVG file which has a similar huge number of nodesd.

I think I would contact Visio support.
  • Inkscape version 0.92.3
  • Windows 7 Pro, 64-bit
Inkscape Tutorials (and manuals)                      Inkscape Community Gallery                        Inkscape for Cutting Design                     



"Be ashamed to die until you have won some victory for humanity" - Horace Mann                       

September 13, 2017, 05:26:06 PM
Reply #4

flamingolady

  • IC Mentor

  • Offline
  • ******
  • Flamingo Lady

  • 154
  • Gender
    Female

    Female
Would using a gradient resolve the color issue, as a workaround?

September 14, 2017, 04:34:07 AM
Reply #5

TransientVagabond

  • Sr. Newbie

  • Offline
  • **

  • 8
Thank you for the replies.

Here's some additional context. So my issue is that I would like to import the path generated by Trace Bitmap, which I think looks quite acceptable SEADOO.svg
*SEADOO.svg
(430.49 kB . 327x222)
(viewed 577 times)
, into Visio. Unfortunately, Visio renders the path incorrectly SEADOO.png
*SEADOO.png
(149.43 kB . 2133x978)
(viewed 600 times)
. My current workaround is to break up the path generated by Trace Bitmap, remove its fill, and apply a stroke to the component paths. Visio can render this SEADOO_Workaround.png
*SEADOO_Workaround.png
(750.93 kB . 2072x1244)
(viewed 623 times)
, but I have double lines where there was once single lines.
  • 0.92
  • Windows 10

September 14, 2017, 04:53:43 AM
Reply #6

TransientVagabond

  • Sr. Newbie

  • Offline
  • **

  • 8
Thanks for your reply.

Too many nodes in a single path may very well be the answer to this issue. I've run into this problem with all my SVGs that have a single path with a high node count. My current workaround is to break up the path generated by Trace Bitmap, remove the fills from and apply a stroke to the component paths. Visio can render this well (see below) even though I still have the same number of nodes, they are distributed amongst many paths. I'm not sure what the cutoff number is. Unfortunately, this workaround results in double lines.

SEADOO_Workaround.png
*SEADOO_Workaround.png
(750.93 kB . 2072x1244)
(viewed 607 times)


I modified an extension to try to apply the correct fill to the broken apart component paths based on overlaps. However, that extension used bounding boxes to detect overlap, which only works in cases where the paths are squarish. I could probably modify my extension to more accurately detect overlaps, but that would take more time and knowledge than I currently have.

My other option is to break up the path with too many nodes using something other than Path > Break Apart so that I don't have any one path with too many nodes. ANYONE KNOW A GOOD WAY OF DOING THIS? I have a few ideas (one is to use an extension that creates a checkerboard pattern and Path > Intersection or Division) but I'd love to figure out something less complicated than what I have in mind.
  • 0.92
  • Windows 10

September 14, 2017, 12:44:26 PM
Reply #7

brynn

  • Administrator

  • Offline
  • ******

  • 3,941
  • Gender
    Female

    Female
    • Inkscape Community
Welcome to the forum!

I could have sworn I replied to this yesterday..... :uhoh:  Anyway, I was going to post that the problem is not related to Trace Bitmap.  The SVG file looks entirely fine.  I was going to post that I thought the problem was related to Visio somehow.

I notice that there was something like 27,255 nodes in the original SVG file.  We have seen that some viewers or other programs have a hard time handling vector file with an excessive number of nodes.

There may have been a single "line" in the orignal SVG file.  But it was actually made up of a compound path - essentially 2 paths (inner and outer).  But in this case, compound, many subpaths.

I'd be curious how many nodes are in the 2nd version of the file?

What you did by breaking apart the path, removing the fill, and applying a stroke, could have been achieved more easily by simply removing the fill of the original SVG, and apply a stroke.

I don't know if that would have fixed it for Visio as well.  And I don't know if any of the work you did, might have coincidentally fixed the problem.  You didn't say that you re-combined the paths, after you broke them apart.  So it could be that simply having many, simple paths, rather than 1 very complex path, fixed it.

You could test, by going back to the original SVG file.  And instead of what you did before, just remove the fill and add a stroke.  The appearance of the drawing will not change.  But it will still be a complex, compound path, rather than what you ended up with, apparently many separate, simpler paths.

Although if you are happy with the result, and aren't planning to do this anymore, maybe it doesn't matter to you.  But if you plan to do it more in the future, it would be helpful to know what it was that fixed the problem.
  • Inkscape version 0.92.3
  • Windows 7 Pro, 64-bit
Inkscape Tutorials (and manuals)                      Inkscape Community Gallery                        Inkscape for Cutting Design                     



"Be ashamed to die until you have won some victory for humanity" - Horace Mann                       

September 14, 2017, 12:50:08 PM
Reply #8

brynn

  • Administrator

  • Offline
  • ******

  • 3,941
  • Gender
    Female

    Female
    • Inkscape Community
Oh, I DID reply to it yesterday.  You've posted the same problem twice.  I'll merge them into one, to avoid additional confusion.
  • Inkscape version 0.92.3
  • Windows 7 Pro, 64-bit
Inkscape Tutorials (and manuals)                      Inkscape Community Gallery                        Inkscape for Cutting Design                     



"Be ashamed to die until you have won some victory for humanity" - Horace Mann                       

September 14, 2017, 12:59:29 PM
Reply #9

brynn

  • Administrator

  • Offline
  • ******

  • 3,941
  • Gender
    Female

    Female
    • Inkscape Community
Ok, so now seeing your reply to my original message, it sounds like the problem was the very complex and compound path, and that breaking it up into smaller and simpler paths helped.  You could try the test I mentioned before, if you want to confirm it.  But that sounds like the problem.

Note that the workaround did not result in double lines.  The original file had double lines as well.  You can't avoid the double lines with Inkscape's Trace Bitmap.  A single line trace would result in single paths, but you might not like how it achieves single lines.  Essentially it makes kind of a knot at every intersection.  So it depends on what kind of quality you need, whether single line trace would help you.

I think Inkscape has an extension that will do a single line trace, but I can't remember where it is.  I wanna say Sourceforge, but I would search Github and Gitlab as well.  Or maybe someone else knows, and they can give you a link?
  • Inkscape version 0.92.3
  • Windows 7 Pro, 64-bit
Inkscape Tutorials (and manuals)                      Inkscape Community Gallery                        Inkscape for Cutting Design                     



"Be ashamed to die until you have won some victory for humanity" - Horace Mann                       

September 14, 2017, 01:11:02 PM
Reply #10

brynn

  • Administrator

  • Offline
  • ******

  • 3,941
  • Gender
    Female

    Female
    • Inkscape Community
One more note.  If you look at your successful result closely, there are a ton of tiny, unnecessary paths.  That's the result of Trace Bitmap trying to "see" those very narrow, and almost sketch-like type of lines in the original.  So if you wanted these paths to be able to cut this out (or plot), I would suggest really perusing the file at high zoom, and cleaning up all those little places.

And also, if you wanted the vector paths for cutting or plotting, a single line trace will certainly not help.
  • Inkscape version 0.92.3
  • Windows 7 Pro, 64-bit
Inkscape Tutorials (and manuals)                      Inkscape Community Gallery                        Inkscape for Cutting Design                     



"Be ashamed to die until you have won some victory for humanity" - Horace Mann                       

September 14, 2017, 03:12:30 PM
Reply #11

TransientVagabond

  • Sr. Newbie

  • Offline
  • **

  • 8
Thanks Brynn.

It looks like the issue is definitely the number of nodes in a single path, Vision still has trouble if I remove the fill from and apply a stroke to the single path.

When I said "double lines" I was referring to appearance (see below).

SEADOO_SINGLE_Line.png
*SEADOO_SINGLE_Line.png
(139.51 kB . 2044x1005)
(viewed 579 times)

SEADOO_Double_Line.png
*SEADOO_Double_Line.png
(179.63 kB . 2019x864)
(viewed 575 times)


  • 0.92
  • Windows 10

September 14, 2017, 03:15:51 PM
Reply #12

TransientVagabond

  • Sr. Newbie

  • Offline
  • **

  • 8
I do agree with you that there are too many nodes/paths overall. Unfortunately, my use case doesn't give me time for manual clean up, and I haven't found a good way of reducing the number. Simplify does not produce good results.
  • 0.92
  • Windows 10

September 14, 2017, 03:26:42 PM
Reply #13

TransientVagabond

  • Sr. Newbie

  • Offline
  • **

  • 8
Here are two SVG files that visually have the same appearance. One has a single compound path, the other is several component paths of the single compound path after the single component path has been broken apart and the correct (Black/White) fills have been applied, which was done automatically by my too-simplistic extension. If there was a simple way to determine whether two paths overlap, I could modify my extension to work for more complicated paths.

Single
Simple Two Box.svg
*Simple Two Box.svg
(2.22 kB . 71x50)
(viewed 520 times)


Broken Apart and Filled
Simple Two Box_Broken_Apart_And_Filled.svg
*Simple Two Box_Broken_Apart_And_Filled.svg
(2.51 kB . 71x50)
(viewed 550 times)
  • 0.92
  • Windows 10

September 14, 2017, 06:41:56 PM
Reply #14

brynn

  • Administrator

  • Offline
  • ******

  • 3,941
  • Gender
    Female

    Female
    • Inkscape Community
I think Simplify would need to be applied to the individual paths, rather than all at once.  I've found that often gives a better result, when there's such a complex drawing.  I'm sure that could be done via extension (although I couldn't say how exactly).

Oh, or you might be able to reduce the nodes somewhat with the settings on the Options tab of the Trace Bitmap dialog.  Probably that area that looks like netting will require a low number for Smooth Corners.  But the Optimize setting might help.  Worth a try?

Somehow I'm not following you.  You mean that you don't want the fills to overlap?  You want it to look like the original trace result, except broken apart into simpler paths?

Ooh, I think I understand what you did.  I wasn't following you before.

Ok, so for each "line" that you broke apart, it originally consisted of 2 paths - already a double path, but forming a single line.  When you broke it apart, you colored the larger of the 2 paths black, and the smaller one white.  (That must have been a ton of work!  Do you mean your extension did that?)

The way to bring that back to a single "line" consisting of 2 paths, is to select them both (one black and one white) and do Path menu > Combine.  I couldn't tell  you how to do that in an extension, but it sounds like you can figure it out.  And I don't know if even that simple compound path would throw Visio off.  It sounds like it might.  But certainly can't hurt to try.

If it does display correctly in Visio, you could try combining a few pairs of paths at once.  Maybe Visio would allow smaller compound paths?
  • Inkscape version 0.92.3
  • Windows 7 Pro, 64-bit
Inkscape Tutorials (and manuals)                      Inkscape Community Gallery                        Inkscape for Cutting Design                     



"Be ashamed to die until you have won some victory for humanity" - Horace Mann                       

September 15, 2017, 01:11:47 AM
Reply #15

TransientVagabond

  • Sr. Newbie

  • Offline
  • **

  • 8
Great ideas. Thanks!

I think you understand me. Ideally, I'd just trace a bitmap and import that bitmap into Visio, but Visio isn't able to deal with single paths that have a high number of nodes. This is why I have to break apart the single path into many, so Visio can handle things.

My extension can only deal with drawings that are squarish. If my extension doesn't work, I just apply strokes to the broken apart paths, which ends up having the double lines, but works in a pinch.

I'll try your idea of breaking apart the path and combining less than all of the paths.
  • 0.92
  • Windows 10