A quick Python tool to transform any picture in a paint-by-number canvas, using opencv
- Picture is resized, denoised and cleaned using morphomat
- K-mean algorithm to detect the k-colors summarizing the best the picture
- Transformation of the picture to match these colors
- Contour detection and drawing of contours on new canvas
- Add label of each shape on the canvas
- Creation of the colormap for the user
A set of PNG pictures in ./inputs
folder, associated canvas and colormaps in the ./outputs
folder
The definition of the class Canvas in the python script canvas.py
- Numpy
- Matplotlib
- OpenCV
run python run.py [path] [nb_color] [plot] [save] [pixel_size]
with:
path: path of the source picture
nb_color : number of colors you want in the canvas (10 to 20)
plot: optional, boolean to set to True if you want to see some plots. Default False
save: optional, boolean to set to True if you want to save results in the ./outputs
folder. Default True
pixel_size: optional, interger, size in pixel of the largest dimension of the output canvas (default 4000)
- Better positioning of the label in each region
- Better contour filtering to remove small regions