Create a mosaic of an input image using smaller images of similar color to each pixel.
Find a file
2021-04-05 10:12:52 +02:00
classes Added sys.argv and input 2021-04-05 08:52:55 +02:00
memory Release 1.0.0 2021-04-05 07:36:26 +02:00
samples dev21w12a 2021-03-22 01:00:54 +01:00
.gitignore Release 1.0.0 2021-04-05 07:36:26 +02:00
create.py Added sys.argv and input 2021-04-05 08:52:55 +02:00
LICENSE Initial commit 2021-03-21 17:00:31 +01:00
README.md Create README.md 2021-04-05 10:12:52 +02:00
requirements.txt dev21w12a 2021-03-22 01:00:54 +01:00

Collage

Create a collage of an image using smaller images

This script attempts to find images of similar color to each pixel of an input image.

demo

Full resolution output (4000x4000px)

Create your own collage

Prerequisites

  1. Install the pip package manager for Python 3.
sudo apt-get install python3-pip
  1. Install dependencies from requirements.txt.
python3 -m pip install -r requirements.txt

Using collage

  1. Add JPG images to use as samples to the samples/ folder. 9999 free sample images.

Sample sets containing images with a mix of different colors and light intensity will in general produce better results.

  1. Run create.py from ~/collage with Python 3.
python3 create.py
  1. Provide an input and output file path when prompted.

You can also pass the input and output file paths as arguments when running create.py.

python3 create.py [path_to_input] [path_to_output]

Download sample images

9999 free 612x612px sample images (~1GB when inflated).

Note that 9999 images are probably overkill if the samples are random enough (which these are). 2000-4000 samples should be enough for most use cases.

Set Size Download
1-2000 193.5 MB Download
2001-4000 192.2 MB Download
4001-6000 191.2 MB Download
6001-8000 380.5 MB Download
8001-10000 191.4 MB Download

Increase / Decrease the output resolution

Resizing the output doesn't require any modification to the underlying code. It does however require that you instance each class manually.

  1. Import the required modules.
from classes.Samples import Samples
from classes.Collage import Collage
  1. Loading the samples with Sample. Nothing exciting here.
samples = Samples("samples",False)
  1. Initialize Collage and define your own self.size tuple.
collage = Collage("path/to/input.jpg",samples)
collage.size = (100,50) # (width,height) of each sample in the collage.

collage.put("path/to/write/output.jpg")

License

This repo is licensed under the MIT License

Issues & Contribute

Report bugs and suggest features by creating an Issue.

Pull Requests to this repo are very appreciated.