Create artistic images using only straight lines
Linepix creates stylized drawings from images by using only straight lines that cross the whole image. Each line touches two different edges of the image. It can also create a video of the image generation process.
Linepix is written in Go. For image generation it doesn't have any dependencies. However, to generate video of the process ffmpeg
must be installed.
go get github.com/hbostann/linepix
# Use default values
linepix -i input.jpg -o output.png
# Make output's width 1024px, aspect ratio is preserved
linepix -i input.jpg -o output.png -w 1024
# Make output's height 600px, aspect ratio is preserved
linepix -i input.png -o output.png -h 600
# Don't resize output. Make it same size as input
linepix -i input.jpg -o output.png -w 0 -h 0
# Draw 7000 lines on the output image.
linepix -i input.png -o output.png -w 1024 -l 7000
# Draw ~3x7000 lines on the output image (since it's color).
linepix -i input.jpg -o output.png -w 1024 -l 7000 --color
# Draw 10000 lines on the output image and generate a video
# with 2000 fps and freeze the last frame for 5 seconds.
# Resulting video length will be NumberOfLines/fps + freeze time
# 10000/2000 + 5 = 10 seconds of video will be generated.
linepix -i input.jpg -o output.png -l 10000 -v -f 2000 -s 5
For more detail use the --help
flag.
Linepix, first finds the darkest pixel in the image. Then it generates lines that go through the darkes pixel with random slopes. It computes the average pixel value along each line and selects the line with the darkest value to be drawn. The value of the selected line is subtracted from the image. After the selected line is drawn on the output image whole process is repeated until the given number of lines are drawn. This process is performed on the grayscale version of the image if the output is not a color image. For color images the input is split into red, green, blue channels and each channel is treated as a grayscale image. Number of lines to draw on each channel is also adjusted by the intensities of each channel. Thus, nearly 3x more lines are drawn on color images.
The MIT License (MIT) - see LICENSE
for more details