Need help cutting images within an image

Post questions on how to use or achieve an effect in Inkscape.
trader4300
Posts: 13
Joined: Tue Jul 11, 2017 5:27 am

Need help cutting images within an image

Postby trader4300 » Tue Jul 11, 2017 6:03 am

I am brand new to the forum. I searched around a bit and could not find any solutions to my problem. Although I came across something called
centerline something or other I could not find any way to install it into inkscape. Remember, I am a newbie to Inkscape but not to drawing packages in general. Pretty good at gimp. I am starting to play around with a laser for cutting marquetry. I have been successful cutting out one simple shape from an outline and having it fit back in. Of course, I get the infamous double lines when doing this. However if I use the inner line on the outline image and the outer line on the inlay image, they fit pretty good. Even better if I scale the inlay image a bit larger. So, after about a hundred hours of reading and playing and more reading about inkscape, I have gotten that far. However, if I try to get more complicated, this issue with the double lines becomes a huge issue and things do not line up very well. I am referring to the simple flower image I have attached. As I said earlier, I can get the
leaves and stem to fit pretty good using the process I outlined above, however it is a different story with the flower petals. I believe this issue results from the common lines between the petals as well as the common lines between the petals and the center. No matter how I cut these, they do not fit back together properly. Now, I only have a hundred hours into this rather simple project (SIC) but I am at my wits end. I don't know where else to look for answers but then I found this forum. Surely some of you have done this before and there is a simple solution right? If not, perhaps inkscape is not the correct package to use for laser cutting of such a design. Like I said, I am new to this technology and would like to learn all I can, so anything you folks can offer is appreciated.
John
Flower.png
Flower.png (31.39 KiB) Viewed 3222 times

Moini
Posts: 3381
Joined: Mon Oct 05, 2015 10:44 am

Re: Need help cutting images within an image

Postby Moini » Tue Jul 11, 2017 7:08 am

If it is really just so simple images, I would recommend you invest some more time into learning how to use the Bézier tool and do a manual trace. Redrawing this flower will only take a couple of minutes, at max (and will probably look better).

Centerline trace (when you get it installed and working) will probably do a fairly good job at images like the above, too.
Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!

Inkscape FAQ - Learning Resources - Website with tutorials (German and English)

trader4300
Posts: 13
Joined: Tue Jul 11, 2017 5:27 am

Re: Need help cutting images within an image

Postby trader4300 » Tue Jul 11, 2017 1:36 pm

This is just a sample image to prove my point. If I am to use inkscape for laser cutting for my marquetry pictures, I will be importing pictures, not creating them, so I will need to know how to use inkscape with the supplied images. This should be a no brainer, but I haven't come across the solution yet, despite all the hours I have spent. Even today, I have spent 6 hours trying to get Centerline Trace installed and running and even that simple task is proving to be monumental.

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

Re: Need help cutting images within an image

Postby brynn » Tue Jul 11, 2017 2:57 pm

Personally, I wouldn't use centerline trace. You'll see when you actually can get it to work. But in corners or almost corners, it makes kind of a knot, which certainly would be a problem for cutting for marquetry. On the github page, you can see examples of the knot that's created.

I guess you could manually node edit those knots, to straighten them out before sending to the cutter. It would depend on how many corners will need to be edited, whether manually tracing the image would be faster than centerline trace, then editing the knots.

For something like marquetry, where you need everything to be very precise, I would not rely on auto trace, with or without centerline trace. I think your best results will be tracing "manually" with the Pen/Bezier tool. (edit - after some practice, you could whip out that flower design in 5 or 10 minutes) Whenever you have places like the flower petals, where you need to have part of a path shared by the path next door, there are a couple of ways to do it.

For an image like the flower you showed, I would use node editing to isolate the shared portion, so that it can be duplicated, and joined to the next petal path. I wrote a tutorial which explains how to make shared borders precisely the same: https://forum.inkscapecommunity.com/ind ... article=47 It's written for beginners.

If you have a very geometric type of design, instead of node editing, you can use path operations, such as Difference or Intersection. Well, you can use path operation for images like the flower. But to me, by the time I've meticulously created the 2nd path, I might as well join the nodes together, instead of performing the boolean operation. But for a geometric design, you can quickly create the 2nd path (rectangle, circle, etc.) Path operations: http://tavmjong.free.fr/INKSCAPE/MANUAL ... ining.html

trader4300
Posts: 13
Joined: Tue Jul 11, 2017 5:27 am

Re: Need help cutting images within an image

Postby trader4300 » Wed Jul 12, 2017 1:51 am

Thanks Brynn for all that. I had read about the knot thing but cant say for sure if I will see this or not cause the dang feature just doesn't seem to work on a windows machine.
I went to your tutorial and tried to follow it. It just seems like a whole lot of work and learning curves to overcome what I think should be a very simple task. I think I am probably looking at the wrong tool to do this job. All the people who are using lasers to cut their marquetry are not going through all this extra work. They simply break their images apart, rotate the pieces to align with the grain, and send them to the laser. It really is that simple.
Inkscape complicates this process by way of the double lines that has to be accommodated in some way, hence my problem.

trader4300
Posts: 13
Joined: Tue Jul 11, 2017 5:27 am

Re: Need help cutting images within an image

Postby trader4300 » Wed Jul 12, 2017 4:43 am

OK Folks, getting closer. I finally got the autotrace program to run within Centerline Trace. However, I am getting all these strange error codes.
Does anyone know why this is happening and why the program just doesn't work properly?

Traceback (most recent call last):
File "centerline-trace.py", line 441, in <module>
e.affect()
File "C:\Program Files\Inkscape\share\extensions\inkex.py", line 283, in affect
self.effect()
File "centerline-trace.py", line 402, in effect
path_svg,stroke_width,im_size = self.svg_centerline_trace(filename)
File "centerline-trace.py", line 292, in svg_centerline_trace
xml = inkex.etree.fromstring(cand['svg'])
File "src/lxml/lxml.etree.pyx", line 3213, in lxml.etree.fromstring (src\lxml\lxml.etree.c:77697)
File "src/lxml/parser.pxi", line 1819, in lxml.etree._parseMemoryDocument (src\lxml\lxml.etree.c:116494)
File "src/lxml/parser.pxi", line 1707, in lxml.etree._parseDoc (src\lxml\lxml.etree.c:115144)
File "src/lxml/parser.pxi", line 1079, in lxml.etree._BaseParser._parseDoc (src\lxml\lxml.etree.c:109543)
File "src/lxml/parser.pxi", line 573, in lxml.etree._ParserContext._handleParseResultDoc (src\lxml\lxml.etree.c:103404)
File "src/lxml/parser.pxi", line 683, in lxml.etree._handleParseResult (src\lxml\lxml.etree.c:105058)
File "src/lxml/parser.pxi", line 624, in lxml.etree._raiseParseError (src\lxml\lxml.etree.c:104201)
lxml.etree.XMLSyntaxError: None

theozh
Posts: 437
Joined: Fri Mar 23, 2012 6:30 pm

Re: Need help cutting images within an image

Postby theozh » Wed Jul 12, 2017 4:53 am

Hi @trader4300, as I understand you need a trace centerline function. In the past, I also needed such a tool. However, I also was discouraged by the installation of this extension (if I remember correctly with some extra Python libraries, etc...)

With a little web search I came across WinTopo.
http://www.softsoft.net/wintopo/index.htm
It makes a good first impression. However, I can't tell whether the freeware version software might install unpleasant features like add-ware, spy-ware or anything else... I don't think so, but nowadays you never know...

With this the process is really simple:
1. Copy your bitmap image to the clipboard
2. Paste (Ctrl+V) your bitmap image into WinTopo
3. Do a "one-touch vectorisation" (F10)
4. Menubar | Edit | Copy Vectors
5. Paste (Ctrl+V) the vectors into Inkscape
Done!
The vectorization of your example flower looks reasonable to me.

Vectorized_Flower.png
Vectorized_Flower.png (25.35 KiB) Viewed 3111 times
Attachments
Vectorized_Flower.svg
(18.3 KiB) Downloaded 164 times
Win7/64, Inkscape 0.92.2

Moini
Posts: 3381
Joined: Mon Oct 05, 2015 10:44 am

Re: Need help cutting images within an image

Postby Moini » Wed Jul 12, 2017 7:15 am

Don't know what's going wrong for you, trader4300.

If I do it like this, it works flawlessly:
- Open Inkscape with empty document (0.92.1)
- Import your flower image
- Select flower image
- Go to Extensions -> Images -> Centerline Trace
- Use my default settings
- Click 'Apply'
- Done (looks more rounded than theo's)
Attachments
Bildschirmfoto_2017-07-11_23-11-22.png
Bildschirmfoto_2017-07-11_23-11-22.png (85.72 KiB) Viewed 3090 times
Bildschirmfoto_2017-07-11_23-13-37.png
Bildschirmfoto_2017-07-11_23-13-37.png (49.85 KiB) Viewed 3090 times
Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!

Inkscape FAQ - Learning Resources - Website with tutorials (German and English)

trader4300
Posts: 13
Joined: Tue Jul 11, 2017 5:27 am

Re: Need help cutting images within an image

Postby trader4300 » Thu Jul 13, 2017 12:41 am

Moini, thanks for verifying that it works on your computer. I will bet you $100 that it was not done on a windows7 machine. That is where the problem lies. I have reported this to the github website in hopes the authors can find the issues with a windows machine.

trader4300
Posts: 13
Joined: Tue Jul 11, 2017 5:27 am

Re: Need help cutting images within an image

Postby trader4300 » Thu Jul 13, 2017 12:57 am

Theozh, I tried reproducing your process. Once I get the image into inkscape, how do I know it is vectorized? I hit the "edit paths by nodes" tool and do not see any nodes. Also, I then tried exporting g-code from this and all I got was some sort of garbage which looked like a raster image or something. What am I missing? My goal is to export clean g-code so I can cut the image with a laser.

Moini
Posts: 3381
Joined: Mon Oct 05, 2015 10:44 am

Re: Need help cutting images within an image

Postby Moini » Thu Jul 13, 2017 2:24 am

Yes, trader4300 - I've been able to reproduce on Win10 and am currently working together with the author on trying to fix (by testing) ;-)
Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!

Inkscape FAQ - Learning Resources - Website with tutorials (German and English)

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

Re: Need help cutting images within an image

Postby brynn » Thu Jul 13, 2017 7:56 am

I went to your tutorial and tried to follow it. It just seems like a whole lot of work and learning curves to overcome what I think should be a very simple task. I think I am probably looking at the wrong tool to do this job. All the people who are using lasers to cut their marquetry are not going through all this extra work. They simply break their images apart, rotate the pieces to align with the grain, and send them to the laser. It really is that simple.


I guess it depends on how precisely you want what you cut to match the image. Any auto-trace will be an approximation. For some simple images, auto-trace can do a good job. But for other images, you might find the approximation is not acceptable.

Yes, it is a lot of work to trace images "manually". But it can't get more precise, if precision is what you need. For the kind of marquetry I remember seeing, it's very detailed, precise, and work-intensive project.

theozh
Posts: 437
Joined: Fri Mar 23, 2012 6:30 pm

Re: Need help cutting images within an image

Postby theozh » Thu Jul 13, 2017 5:08 pm

trader4300 wrote:Theozh, I tried reproducing your process. Once I get the image into inkscape, how do I know it is vectorized? I hit the "edit paths by nodes" tool and do not see any nodes.

I do not know what you have done exactly. I do see nodes.
Have you used WinTopo? In WinTopo, have you "Copied vectors" NOT just copy (Ctrl+C)? What is displayed in the Inkscape status line if you select your "Vector Object"? Could you upload your Inkscape file?

Vectorized_Flower2.png
Vectorized_Flower2.png (42.44 KiB) Viewed 2957 times
Win7/64, Inkscape 0.92.2

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

Re: Need help cutting images within an image

Postby brynn » Thu Jul 13, 2017 5:42 pm

I haven't tried to use the other trace engine that's being discussed. But from what I see in the image just above this, it doesn't look like what trader4300 needs. It looks like there is only a single path between the flower petals. As far as I understand, there should be 2 overlapping path segments there. One belonging to the path of one of the petals, and the other belonging to the path of the petal next to it.

In other words, what happens if you use Path menu > Break Apart on that trace? The result needs to be 5 petals and a center object, the stem and 2 leaves. 9 closed paths. I can't predict how it would break apart, by just looking at it. But if there were overlapping nodes, they would be visible (half the size of a single node). And I don't see any.

Even using centerline trace, you'll still need to do some node editing - as far as I understand.

theozh
Posts: 437
Joined: Fri Mar 23, 2012 6:30 pm

Re: Need help cutting images within an image

Postby theozh » Thu Jul 13, 2017 9:20 pm

OK, I see, I was just focussing on the trace centerline which is the first step.
Well, if you need to laser cut 5 different petals & center (probably out of different materials) the only way I see is to break this path apart (Shift+Ctrl+K and additionally maybe with F2/break path at selected nodes) and duplicate the lines and then newly combine your petals. How should the program know what a petal is and which lines are double borders? This definitely will require some manual work.
On the otherhand, if all petals are out of the same material sheet, wouldn't it be enough if the laser cuts along the single line? For the center you would have to create an own object by duplicating the necessary lines.
And if you exactly cut the petal along the "shared" lines, might it be too close/loose to fit? Then you could play with in-/outsets (Menubar | Path | Inset/Outset).

Vectorized_Flower2_BreakApart.png
Vectorized_Flower2_BreakApart.png (42.19 KiB) Viewed 2927 times
Win7/64, Inkscape 0.92.2

theozh
Posts: 437
Joined: Fri Mar 23, 2012 6:30 pm

Re: Need help cutting images within an image

Postby theozh » Fri Jul 14, 2017 4:33 am

another idea:
it might also work even without vectorization of the original image.
1. With such a black & white bitmap you could use the "Bucket Tool" (Shift+F7).
2. fill the areas of the petals, leafs and the stem.
3. delete the bitmap image
4. remove the fill and set a stroke. These paths should be the laser cut paths.

However, I have to admit that I still haven't completely understood how the "Fill bounded areas"-Tool really works. How it really fills the areas, sometimes with more or less precision at some locations.
In case you have vectorized your original bitmap image you might be a bit more flexible in terms of defining the gaps between your cutting paths.

BucketFill_Flower.png
BucketFill_Flower.png (67.88 KiB) Viewed 2892 times
Win7/64, Inkscape 0.92.2

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

Re: Need help cutting images within an image

Postby brynn » Sun Jul 16, 2017 4:48 pm

theozh wrote:Well, if you need to laser cut 5 different petals & center (probably out of different materials) the only way I see is to break this path apart (Shift+Ctrl+K and additionally maybe with F2/break path at selected nodes) and duplicate the lines and then newly combine your petals.


That's exactly why I suggested manual tracing and node editing from the start. At first, manual tracing and node editing seems time consuming. There is a small learning curve. But once you have a grasp on how to do it, it gets faster and faster. And for an image as simple as this, I'd say it could be traced in 15 minutes by a newbie. Give another 15 for the node editing. But with some practice, the whole thing could be finished in 15 minutes.

I don't know what trace engine he said the other marquetry makers were using, where they imported the raster image, and the cutting paths were magically created. Maybe they have a been downloading files which show the parts which are needed, already individually separated?

I would definitely not suggest using the Bucket tool (fill bounded areas) for this. It will be even less precise than auto tracing.

Although apparently precision is not needed by trader4300. So maybe he'll be interested?


Return to “Help with using Inkscape”