Skip to content

Continuous-line drawings interpreted as solutions to the traveling salesman problem

License

Notifications You must be signed in to change notification settings

kalyaninagaraj/TSP-Art

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TSP-Art a la Robert Bosch

Continuous-line drawings interpreted as solutions to the traveling salesman problem, in the style of Robert Bosch.

About

This repository is home to Python code that approximates a given .pbm image with a continuous-line drawing that is a solution to a traveling salesman problem.

    

To get the TSP tour-like image of Hank Marvin -- the image on the right -- do the following. First, use an image editor like Gimp to to get the stippled image in the middle by following these steps by Evil Mad Scientist Laboratories. It's easy to read the co-ordinates of the stipples when the stippled, or dithered, image is stored as a Portable Bit Map (PBM) file. For now, this code can handle only a type P1 PBM file --- the kind that stores the image's bit map in ASCII format. Next, send the co-ordinates to a TSP solver like Concorde. This code submits a job to the NEOS Server with Concorde set to the Lin-Kernighan heuristic. Finally, convert the returned tour sequence into an SVG image in Inkscape.

To Run Code

Run the script file Script.sh under folder CODE

> cd CODE/
> sh Script.sh HM black 1.3

The last command takes IMAGES/HM.pbm as input and returns a black line drawing IMAGES/TSP_IMAGES/HM.svg of the original image with line thickness 1.3px.

Things To Note

Starting with a "good" stippled image can make a world of difference to the aesthetic quality of the TSP line drawing. Robert Bosch and his collaborators write of several approaches (algorithms) to generate that "good" starting point. I took the easy way out and followed the Evil Mad Scientist's Gimp-based approach. It's the messier of the two routes (the other one being coding up the algorithms used by Bosch) in the sense that it can't be automated and requires relying on your eye.

Code Credit

  1. Ideas on reading PBM files in Python were borrowed from Evil Mad Scientist Laboratories' code for the same. Check it out.
  2. @kalyaninagaraj

Photo Credit

The image of Hank Marvin is cropped from a group photo of The Shadows that appears in the public domain.

References

  1. Robert Bosch makes art by performing mathematical optimization. This book review in the Scientific American of his book Opt Art is a great starting point.
  2. Check out all of Bob Bosch's Mathematical Art and the art of his inspiration, Ken Knowlton.

About

Continuous-line drawings interpreted as solutions to the traveling salesman problem

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published