4

I have an svg file composed of multiple shapes, and I would like to perform edge detection to create a path around the border of the image.

Basically, I want the equivalent of Path --> Trace Bitmap, but for an image that is already a vector image. I tried using that Trace Bitmap already and it does not do anything.

4

If they are shapes, select them all, duplicate them, then union them into one shape.

  • 2
    Some are paths. – merlin2011 Apr 5 '15 at 4:45
  • @merlin2011 you can convert those to shapes after duplicating. – DA01 Apr 5 '15 at 4:47
  • 1
    I posted a new question as a follow-up. – merlin2011 Apr 5 '15 at 7:36
4

The quickest solution I can think of to trace a path around a clump of shapes is by using the bucket fill tool. First draw a colored box (to constrain the bucket fill) around the shapes, select the box and zoom to selection.

Next, select the bucket fill tool and set its threshold to 10 or more, so you'll have a smooth fill. (Also set the stroke to something large, say 6 pixels and no fill so you can clearly see the result). Click with the bucket fill tool between your box and the group of shapes enter image description here

The resulting bucket fill will also have a border on the edge of your colored box. enter image description here

Just remove the outer shape by selecting the outer shape's nodes with the node tool then deleting them: enter image description here

You can now move the border to the back of the group of shapes, color the stroke or increase its thickness, or give it a fill. Delete the box if you like. enter image description here

If there is a bitmap included in the group of shapes, I would first trace a path with a thick stroke around the bitmap to have a smooth, uniformly colored edge to trace on before doing the bucket fill. enter image description here

This might not be very accurate – notice there are a few rounded corners where they should be sharp. This can be corrected by using the node tool. If I want a more accurate border, I would go with doing a union operation on all vector shapes, including the shape I placed around a bitmap (I might even enlarge the resulting shape by giving it a thick stroke, converting the stroke to paths, breaking apart the path, and keeping only the outer shape as border).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.