Single Line Art / Traveling Salesman Problem Tutorial
The “Traveling Salesman Problem” (“TSP”) is a problem studied in mathematics where one tries to figure out the shortest path through a number of points. Solving for the absolute shortest route can take a lot of processing power and time, but getting a pretty good approximation can be very quick. The Eggbot, MakerBot Unicorn, and drawing robots are particularly well suited to these kinds of drawings.
Recently I tried to create some of my own single line / TSP art based using the awesome Evil Mad Science TSP guide. In doing so I think I may have figured out a way simplify the process slightly for Windows users. 1 The EMS guide has the user install Cygwin in order to provide certain elements of Unix for running the Concorde or Linkern TSP solvers. However, I accidentally discovered that once you have the “cygwin1.dll” out of the Cygwin installation, all you need to do is create a batch file for automating the TSP conversion. So, start to finish, here’s how I do it:
Programs / Scripts
- Download and install the free open source Python programming language
- Download and install the free open source GIMP image manipulation software2
- Download the Evil Mad Scientist Eggbot scripts for creating TSP vector art. You’ll want the file named, “tsp_art_tools_0_8_3.zip”
- Download the Linkern TSP solver from Georgia Tech’s website
- Download the “cygwin1.dll” file for running the Linkern TSP solver on a Windows platform
- Put the “cygwin1.dll”, “linkern.exe”, “tspart.py” , “tspbitcity.py”, “tspsolution.py” into a folder location of your choice
Make a Grayscale Image
- Open your image in GIMP
- Turn the color information monochrome “Image -> Mode -> Grayscale“
- Open the color levels “Colors -> Levels“
- Wash out the image by adjusting “All Channels” in the pop-up window to some value to 2003
Make a Stippled Image
- Turn the washed out grayscale image into a stippled image “Create Image->Mode->Indexed“
- Select these options in the pop-up window
- Use black and white (1-bit) palette): Checked
- Remove unused colors from colormap: Checked
- Color dithering: Floyd-Steinberg (normal)
- If given the option, choose to save the PBM file in the “Raw” format
Create a Batch file to automate the Stippled Image to a TSP Line Drawing conversion
- Open “tspart.py” with your favorite text editor4 and change line 76
- From: LINKERN = ‘C:\linkern.exe’
- To: LINKERN = ‘C:\FILELOCATION\linkern.exe’
- Save “tspart.py”
- My Python directory is located at “c:\python\python”
- My scripts are located in a subdirectory on my desktop “c:\python\python C:\Users\MakerBlock\Desktop\TSP\scripts\tspart.py”
- My PBM file is also located on my desktop “C:\Users\MakerBlock\Desktop\TSP\images\drawing.pbm”
- c:\python\python C:\Users\MakerBlock\Desktop\TSP\scripts\tspart.py C:\Users\MakerBlock\Desktop\TSP\images\drawing.pbm
Use the Batch file to convert the Stippled Image to a TSP Line Drawing
- Double-clicking the batch file will convert “drawing.pbm” into “drawing.svg”
- To convert your next file, you can either name it to “drawing.pbm” or edit the Batch file to reflect a different PBM file name.
If you haven’t tried to create some single-line-artwork yet, give it a shot today! It’s a lot easier than it looks and the results are really satisfying!
Once you’ve gone through the above process once, it goes super quickly the second time. You basically make your image grayscale, wash it out, save as a stipple file format, and then run the batch file. The entire process takes about two minutes once you get the hang of it – with a full minute and a half or so just devoted to letting the TSP program do its thing.
Error - could not find Thing 19042.