This repository contains a Python implementation of a photomosaic generator. A photomosaic is a large image composed of smaller tile images. This project allows you to create your own photomosaic using a base image and a directory of tile images.
The photomosaic generator works by first calculating the average color of each tile image and the corresponding region in the base image. It then uses a K-D tree, an efficient data structure for nearest-neighbor searches, to find the tile image that most closely matches the color of each region in the base image. The result is a mosaic image that closely resembles the original base image.
- Python 3.7 or above
- NumPy
- OpenCV
- scikit-learn
- colorspacious
To install these packages, run:
pip install numpy opencv-python scikit-learn colorspacious
- Clone the repository:
git clone https://github.com/VeritasV/python-mosaic.git
- Navigate to the repository directory:
cd python-mosaic
- Place your base image in the repository directory and name it target.png
- Create a tiles directory in the repository and place your tile images inside it.
- Run the script:
python main.py
- The resulting mosaic image will be saved in the current directory.
Your contributions are always welcome! Please create a pull request to add new algorithms, improve the current implementation, or fix bugs.
If you find this project helpful or interesting, please consider supporting me on BuyMeACoffee.
This project is licensed under the MIT License - see the LICENSE file for details.