|
|
Tgif FAQ - Bitmap to Vector Conversion
|
(Polish version of this page)
|
|
How do you convert a bitmap graphic
to a vector graphic?
|
-
Well, it takes a little bit of work. Let me illustrate this with an
example. I've just scanned in
a logo from my University of Maryland notebook.
I scanned it with gray scale because I want to convert it into a
vector graphic. (This procedure also works for color graphics.)
If you have tgif (version 2.16 or newer) installed, do the following to
see the final result:
- tgif
http://bourbon.usc.edu/tgif/faq/turtle-m.obj.gz
- (If you'd like to see the vector parts, just select an object
and keep selecting UnGroup() from the Arrange Menu.)
Here are the steps I used to create the vector graphic.
- Pin the ImageProc Menu because I'll be using quite a few
operations from it. Then I do the following:
- Select ImageGIFFile() from the File Menu and import the GIF image.
Tgif uses giftopnm and ppmtoxpm from the
netpbm package to convert the GIF
file to an XPM file and then import the XPM file.
- Select the image and click on ContrastEnhance() from the ImageProc
Menu. Enter a value like 5.
Select FlushUndoBuffer() from the Edit Menu and read the Message
Window to see how many colors are left in the current image.
Repeat this step if the image contains more than just
black and white colors.
- Save the file.
- Increment the grid to the maximum by repeastedly selecting
+Grid() from the Layout Menu. This is done so that you
can accurately move out created pieces of the turtle.
- Get rid of unwanted parts of the image by changing the color of
these parts to the same color as the background color of the
image (in this case it's white). So change the current color to white.
- Select the image and click on FloodFill() from the ImageProc Menu.
Keep clicking the unwanted parts until all of them are gone.
Click the middle button to terminate FloodFill().
- Change the current color to something like blue or red (or anything
other than black and white) so you can see what you are doing.
Change the fill to NONE and pen to a solid foreground pen.
- Select the image and click on CreateContour() from the ImageProc Menu.
First you need to create the outline of the turtle object.
Since tgif finds the starting point of a contour by going left from
the point of the click, you should click just outside the
turtle object and to the right of the turtle. Once you get it right,
select Group() from the Arrange Menu. Move the outline away from
the bitmap using the cursor keys. Remember how many times you
press the keys because you need to do the same move for every piece
of contours. Change the fill of the outline to solid foreground.
- Now comes the tricky part. You will need some practice before
you get good at this. Image the image as if it's constructed by
layers and always work from the back of the image
towards the front of the image.
- Select the image and click on CreateContour() from the ImageProc Menu.
Click somewhere inside the turtle to create a contour. Select
Group() from the Arrange Menu. Change the fill to either the
solid foreground or the solid background fill. Move the piece out
and place it on top of the outline. Repeat this step until you get
every piece.
- Finally, select each individual part and change its color by
selecting AddColor() from the Edit Menu.
If you'd like to create vector art from scratch using tgif, please
visit ONIZUKA's Home Page mentioned in the Miscellaneous section of tgif's home page.
|
|