dotter
所属分类:Leetcode/题库
开发工具:C
文件大小:0KB
下载次数:0
上传日期:2017-11-05 19:29:18
上 传 者:
sh-1993
说明: 使用圆形近似图像,用于编程挑战。,
(Approximates images using circles, made for a programming challenge.,)
文件列表:
10000.png (255679, 2017-11-05)
100000.png (592496, 2017-11-05)
1000000.png (584413, 2017-11-05)
Makefile (152, 2017-11-05)
dotter.c (7050, 2017-11-05)
stb/ (0, 2017-11-05)
# dotter
Takes an image and tries to approximate it with circles.
Requires libpng
## Arguments
`./dotter [input.png] [output.png] [iterations] [radius] [make_slices]`
Don't forget to pull in the submodules before compiling.
## Procedure
Load an entirely black image into variables img1 and img2.
Pick a random color in the input image, and draw a dot of that color at a random position in img1.
Compare img1 to the source and compare img2 to the source.
If img1 is a closer approximation to the source, copy img1 to img2. Otherwise, copy img2 to img1.
Repeat for the given number of iterations
## Optimizations
Only the affected pixels need to be copied between the images, and only the affected pixels need to be compared.
I implement both of these optimizations, which vastly decrease runtime
## Samples
10000 iterations
![](https://github.com/nilesr/dotter/blob/master/10000.png)
100000 iterations
![](https://github.com/nilesr/dotter/blob/master/100000.png)
1000000 iterations
![](https://github.com/nilesr/dotter/blob/master/1000000.png)
近期下载者:
相关文件:
收藏者: