• Stars
    star
    531
  • Rank 83,129 (Top 2 %)
  • Language
    Python
  • License
    MIT License
  • Created over 10 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Python script for creating photomosaic images

mosaic

This utility can be used to generate photo-mosaic images, to use it you must have Python installed, along with the Pillow imaging library.

As well as an image to use for the photo-mosaic (most common image formats are supported), you will need a large collection of different images to be used as tiles. The tile images can be any shape or size (the utility will automatically crop and resize them) but for good results you will need a lot of them - a few hundred at least. One convenient way of generating large numbers of tile images is to extract screenshots from video files using ffmpeg.

Run the utility from the command line, as follows:

python mosaic.py <image> <tiles directory>
  • The image argument should contain the path to the image for which you want to build the mosaic
  • The tiles directory argument should contain the path to the directory containing the tile images (the directory will be searched recursively, so it doesn't matter if some of the images are contained in sub-directories)

For example:

python mosaic.py game_of_thrones_poster.jpg /home/admin/images/screenshots

The images below show an example of how the mosaic tiles are matched to the details of the original image:

Mosaic Image
Original

Mosaic Image Detail
Mosaic Detail (click through for full mosaic ~15MB)

Producing large, highly detailed mosaics can take some time - you should experiment with the various configuration parameters explained in the source code to find the right balance between image quality and render time.

In particular the TILE_MATCH_RES parameter can have a big impact on both these factors - its value determines how closely the program examines each tile when trying to find the best fit for a particular segment of the image. Setting TILE_MATCH_RES to '1' simply finds the average colour of each tile, and picks the one that most closely matches the average colour of the image segment. As the value is increased, the tile is examined in more detail. Setting TILE_MATCH_RES to equal TILE_SIZE will cause the utility to examine each pixel in the tile individually, producing the best possible match (during my testing I didn't find a very noticeable improvement beyond a value of 5, but YMMV).

By default the utility will configure itself to use all available CPUs/CPU-cores on the host system, if you want to leave some processing power spare for other tasks then adjust the WORKER_COUNT parameter accordingly.

More Repositories

1

homoglyph

A big list of homoglyphs and some code to detect them
JavaScript
514
star
2

image_augmentor

Data augmentation tool for images
Python
440
star
3

bitmeteros

BitMeter OS - a cross-platform bandwidth monitor
C
330
star
4

reading-list-mover

A Python utility for moving bookmarks/reading lists between services
Python
200
star
5

markov-text

Python utility that uses a Markov Chain to generate random sentences using a source text
Python
185
star
6

moment-precise-range

A moment.js plugin to display human-readable date/time ranges
JavaScript
150
star
7

bayesian-classifier

A Naive Bayesian Classifier written in Python
Python
102
star
8

star-charts

Generate SVG star charts using Python
Python
100
star
9

mazes

JavaScript Maze Generator
JavaScript
64
star
10

monkeyshine

A collection of slightly evil JavaScript
JavaScript
45
star
11

lunar-calendar

Generates an HTML Lunar Calendar
HTML
42
star
12

old-time-radio

An internet radio station streaming classic shows from the Golden Age of Radio
JavaScript
34
star
13

convnet-designer

A utility for designing Convolutional Neural Networks
JavaScript
27
star
14

readable-regex

Java library for creating readable regular expressions
Java
26
star
15

javabean-tester

JavaBean Tester
Java
24
star
16

js-planet-phase

A small JavaScript library for rendering realistic moon and planet phases in HTML
JavaScript
22
star
17

table-sorter

Table Sorter
JavaScript
21
star
18

clipper

Page Clipper Bookmarklet
JavaScript
21
star
19

generative-patterns

Web-Based Generative Pattern Maker
JavaScript
19
star
20

wordvis

This is a Python script to generate Sunburst Charts that visualise the structure of English words.
Python
16
star
21

process-roulette

A shell script game where you kill random processes on your computer, the more you kill the higher your score!
Shell
14
star
22

sarsa-lambda

A Python implementation of the SARSA ฮป reinforcement learning algorithm
Python
11
star
23

regex_parser

A regular expression parser written in JavaScript
JavaScript
10
star
24

https-certificate-expiry-checker

A Python script for checking when HTTPS certificates will expire
Python
10
star
25

star-rise-and-set-times

A browser-based tool for calculating the rising and setting times of stars
JavaScript
9
star
26

connect4

Python
8
star
27

blockchain

Minimum Viable Blockchain in Python
Python
8
star
28

maze.js

Maze Generation Algorithms and Rendering Code
JavaScript
8
star
29

save-restore

Save/Restore Bookmarklet
JavaScript
8
star
30

boggle

A boggle solver and game
Python
7
star
31

bokeh

Bokeh Animation with JavaScript
JavaScript
7
star
32

video-barcode-generator

Video Barcode Generator
Shell
6
star
33

show-passwords

Show Passwords Bookmarklet
HTML
6
star
34

scheme-interpreter

An interpreter for a basic subset of the Scheme programming language
Python
6
star
35

algorithms

Python
5
star
36

solar-system-moons

Python code for generating infographic posters that visualise data about the outer planets in our solar system
Python
5
star
37

top-down-parser

A simple top-down parser written in JavaScript
JavaScript
4
star
38

magnetic-pendulum

An interactive simulation of a Magnetic Pendulum
JavaScript
4
star
39

planetary-systems

Python code to generate an SVG showing planetary systems
Python
4
star
40

stellar-classification-parser

A parser for star classification codes
JavaScript
4
star
41

bitmeteros-python-client

A graphical client for BitMeter OS
Python
4
star
42

zen.sh

A shell script meditation timer for macOS
Shell
3
star
43

netmo

Browser-based remote network monitoring tool
Python
3
star
44

gradient-descent

Python implementations of both Linear and Logistic Regression using Gradient Descent
Python
3
star
45

neural-net

A simple neural network implemented in Python
Python
2
star
46

hltracker

Hotline Tracker
Visual Basic
2
star
47

crypto-tools

Python
1
star
48

twitter-min

Minimalist Twitter Search Client, contained in a single HTML file
HTML
1
star
49

analog-digital-clock

Analogue/Digital Clock
JavaScript
1
star
50

peg-parser

The beginnings of a Parsing Expression Grammar parser
Python
1
star
51

landscape

JavaScript
1
star
52

ball_stand

A 3D model of a ball-stand, useful for displaying the clear acrylic balls often used for contact juggling.
OpenSCAD
1
star
53

reinforcement-robot

Experiment with Reinforcement Learning using robots!
JavaScript
1
star
54

tcpdump-web

A web interface for tcpdump
JavaScript
1
star
55

wordle.sh

A Wordle-solving shell script
Shell
1
star
56

svg-stars

Generate pretty animated SVGs for stars
JavaScript
1
star