Create string art from image, using python
This script attempts to approximate a given image by a series of strings/lines connecting 2 points along the circumference of a circle centered at the image center.
- Convert image to gray scale, and scale width to 400 pixels.
- Blur slightly, invert intensity and threshold using Otsu thresholding.
- Clip the image to within the center circle.
- Compute Hough transformation on the thresholded image.
- Given the number of points (N) on the circle, compute Hough parameters for all possible lines linking all
N*(N-1)/2
. - Compute allowed Hough parameter space based on results from step 5.
- Pick iteratively peaks from the Hough transformation, and for each peak within the allowed Hough parameter space, add a line with 2 end points on the circle.
Currently it is not working quite well. The output is sensitive to the type of image and a few parameters. Any improvement or suggestion is appreciated.
Tested in python2.
Requires:
- numpy
- PIL
- skimage
- matplotlib