Categories
Uncategorized

Vector to Raster and back…

Encoding Discs

While Inkscape is a great and powerful open source vector editing application, sometimes it can’t do it all. Since I primarily use it for creating files for laser cutters, vinyl cutters, the Egg-Bot, etc. I need to have lines. No fills, no objects sitting on top of other objects, no crazy intersections of paths, just lines.

I’ve found that on occasion it’s actually easier to export a raster image, re-import it, and trace it to get the needed vector file. I’ve done this for many files from OpenClipArt.org because they weren’t created with CNC uses in mind, but that’s what I use them for.

Back when I wrote my rotary encoding post I mentioned a perl script that could create encoding disks. It’s simple to use, and outputs an SVG file that I can open in Inkscape. Sadly, it’s not exactly what I need, but it’s pretty close, and easy to fix.

Encoding Disc

Here’s the disk that was created, which uses some neat SVG capabilities to generate it, but makes it quite difficult to edit using Inkscape. You can’t ungroup it, or break it apart, or use union or difference commands on it.

Encoding Disc

I’ve placed a smaller disk on top of it, Right now it’s gray (just so you can see it) but I’m going to fill it with white and give it no stroke. (Normally I would place one object on top of the other and use the difference command to cut a hole in the larger object. In this case, that can’t be done.)

Export at PNG

Once that’s done it looks like I want it to look, but it’s not all lines. It’s really overlapping objects. As long as it looks like I want it to look, I can export it as a bitmapped file. (A PNG file, to be precise.)

Import PNG

Here’s the PNG file. It’s raster, not vector, and again, it looks just like I want it to look. Excellent! Let’s go back to Inkscape and import the PNG file.

Trace Bitmap

Once imported I can use the Trace Bitmap command to easily change this black and white image into a vector file. (Yes, make sure it’s just pure black and white, so it can easily separate the two colors and create the needed path.)

Outline

After the bitmap has been traced I’ve got nice vector lines, shown here in outline mode, and it’s ready to be cut with a CNC machine. (Oh, I’ll probably add a center mounting hole, as the encoding disk eventually does need to attach to something.)