Photo to drawing
2020, Jan 10
The goal : from an any photo, find a representation of the image that could be drawn.
Example :
From this, we could add colour and have a perfectly drawable representation of our original landscape.
A fast implemntation
3 easy steps :
- Sample N random spatial clusters in the image
- For each cluster, find the mean color
- Reduce the number of colours to M by clustering the color of the image
Results
The result with 1000 clusters and 20 colors
Bonus : drawing only the boundary
If the region are small enough, drawing the boundary of the cell could be enough to get the idea.
To do so, we can follow these 4 easy steps :
- Get the eqaation of the mediator line for all pair of centers
- For each point of the line, determine if their are indeed closer to the two centers than the others. These point are the boundaries we are looking for.
- Plot two line for each line, one of each center color.
The code
Do it and see by yourself that it is not a very powerful way to do it.
However the performance of the raw implemntation is pretty poor. It takes large amount of time for small img and the scaling is horrible.
Part 2 of this post will look at solving these issues.
The code is available here