Quantcast
Channel: Inhale 3D » inkscape
Viewing all articles
Browse latest Browse all 2

Bitmap to Vector Transformations in Inkscape

$
0
0

A critical skill in transforming logos and other images into 3D objects is the ability to transform a bitmap into a vector-based file format.  The basic concept is you need to be able to create a file that’s a trace of a bitmap as if you sat down and traced it with a pencil on some velum.  If you don’t have the good fortune of starting with or making your own vector graphic (maybe a client hands you a bitmap and you have to make due), then you need this technique in your arsenal: converting a bitmap to a vector graphic.

3D is Vector

CNC routers, 3D printers, and laser cutters are all inherently vector technologies. A 3D printer lays a bead of plastic or chocolate down from one point to another. A CNC router and laser cutter makes a cut from one point to another.  A vector consists of a starting point (X,Y,Z coordinate), a direction and a velocity – this basic mathematical definition helps describe these three 3D technologies.

There are a lot of articles out there on the difference between vector and bitmap graphics so read up on the differences if you’re not sure.  If you have a PNG, JPG, GIF, or BMP file, for example you have a bitmap file.  If you have an AI, EPS, PS, STL, or OBJ  you have a vector file.  This technique assumes you’re starting with a bitmap file which are everywhere on the web.  In most cases, the graphics you see in a web browser are all bitmap files (not always, but 99% of the time.)

In future articles, I’ll show you the myriad of fun things you can do with the resulting vector formatted file, but for now, trust me, learn this technique if you don’t know it. 

Before going any further, make sure you download and install Inkscape, the vector graphics tool we’ll use for this tutorial.  Inkscape is a cross-platform, open source, free tool that is a great alternative to Adobe Illustrator.  I’ll use Inkscape across tutorials on Inhale 3D and I think it’s well worth the investment of time to learn it. 

Start with a Bitmap Logo

For this example, we’ll use the Serranos Coffee logo.  These guys are just down the street from my office and I’ve taken my kids there since they were in diapers.  The owner, Carl Nolt, was the original roast-master for Seattle’s Best Coffee, so if you are ever in Southern Colorado, stop at Serranos for a treat.   You can click on the logo below to get the larger version and then right-click and save it if you want to follow along.

18146 221249582815 3707560 n

Assuming you saved this as SerranosLogo.png, open it in Inkscape.

SerranosLogo png  Inkscape 1

Next select the graphic and a set of controls will appear on the outside of the graphic:

SerranosLogo selected 1

Then go to the Path menu and select Trace Bitmap…

X11 1

After selecting Trace Bitmap, you’ll get a fairly obtuse dialog that looks like this (hit the Update button and the graphic will appear in the little preview window as shown below):

Tracebitmapdialog

Hit “OK” and then you’ll see the main window change to something like this:

Bitmaptrace overlap

The tricky thing that happened is that Inkscape created a whole new graphic that is the trace of the original bitmap and plopped it directly over the top of the original bitmap – you can see just a hint of red peaking out around the black lettering.   That red is the original bitmap and the black is the new traced bitmap which is now in vector form.

If you select and drag one of the images, you’ll see that there are indeed two images now:

BitmapAndVector

We only want to keep the black and white for the rest of this tutorial, so select the colored image and hit your delete key to remove it from the work area and you’ll be left with just the traced version:

SerranosLogo Traced

Astute readers will notice that while it’s a pretty good facsimile of the colored version of the logo, certain things didn’t come through very well – take a look at the Registered trademark symbol up close by zooming in on it with the magnifying (zoom) tool:

Thresholdgamachie

Lets see if we can clean that up.  Hit Ctrl-Z (Undo) a couple of times until you see the colored logo return to your work area, then select the black and white logo and delete it…we’re going to remake it, this time by tweaking some of the trace bitmap parameters in the dialog you saw earlier.  Select the colored logo and go to the Path menu and select Trace Bitmap… to get the dialog back up.

These sorts of issues come from the threshold used to determine if there should be a line or no line to represent the pixels that were in the original image. Tracing a bitmap is very much like using pencil lines to represent the pixels or dots of the original image, so instead of painting with dots it’s using line segments.  It’s not perfect, but you can tweak it to make it better.

If you lower the Brightness Cutoff threshold to 0.2 as shown below then hit the update button to update the little preview, you’ll see that this goes the wrong direction:

Threshold2trace

and if you go to say 0.9, it is the right direction, but comes out too heavy:

Threshold2tracebitmap

 If you hit OK and accept this, but then zoom in on the registered trademark symbol you’ll see it’s so heavy it’s almost completely filled in:

Threshold3tracebitmpa

So, the best value is somewhere in between.  I settled on 0.7.  Each image will be different and you’ll need to decide which details are import to try to maintain the best you can:

Threshold 7 tracebitmap

As before, you need to remove the original colored bitmap image and keep just the black and white.  With this image, we simply need to save it as a vector format and our machines can print or cut it on whatever material we select.   From Inkscape File menu, choose “Save As…” and select a vector file format such as EPS, SVG, or DXF.  

While I have the patient open, I will almost always make three separate files doing a Save As… DXF, SVG and EPS.  These are the most flexible formats for later use.

To give you a taste of what’s coming, once this file is imported into other 3D tools I’ll introduce later, you can have all kinds of fun with it, like start turning it into a 3D object.  Here are a few 3D extruded elements of the logo after it was imported as a DXF file into a 3D CAD tool – the fun really starts when you start adding the 3rd dimension:

2dTo3d

Summary

Bitmap to vector graphic transformations are used over and over again in CNC, 3D printing, and laser cutting operations.  This is one of the foundational techniques to learn to start doing fun stuff with these tools.

Related Links

Bitmap Tracing in Inkscape

Manual tracing in Inkscape


Viewing all articles
Browse latest Browse all 2

Trending Articles