Mosaic image creator
Create a mosaic-like picture collage that consists of multiple input images. Each tile gets chosen according to best matching color values.
mosaic
can assemble collages of a picture by combining smaller squares of some given image pool.
More technically speaking, the input file is split into tiles of a fixed size and for each of those,
another image is selected as overlay that resembles its color best.
This kind of transformation should be well known and there might already be more advanced tools
available for this purpose. However, mosaic
does not require manual interaction and does not come
with an excessive amount of dependencies, except for
libjpeg
.
The above example shows the input image, the resulting collage, and a zoom on the result in original size.
Creating photo collages
In order to create a mosaic collage of an input image, provide the output filename and a pool of pictures to use as tiles:
./mosaic [--dim=...] [--tint=...] [--fulltint=...] [--dist=avg|euclid|lab] input.jpg output.jpg sample_1.jpg...
The following optional arguments are supported:
dim
- specifies an even number that defines the tile dimensions in pixels, default: 40
tint
- “fake” tile colors by shading it with the average input color, default: 50 (%)
fulltint
- similar to
tint
, this is for the whole image, default: 10 (%) dist
- when comparing images in color space, this gives the color distance weight function to use, default: lab (best, slowest)
If the result is not quite satisfying, the image pool might be too small or uniform – i.e. the best
available sample found for a tile is not good enough.
The tint
option improves the result by an overlay of the desired color: Each tile gets mixed with
the average color it should resemble at this position. In addition, by fulltint
, the final result
can be shaded with the original input image for better contrast and resolution.
Installation
For building the binary locally from the sources, simply type make
.
The only uncommon dependency is the libjpeg-dev
package or similar.
Use then for example something like:
./mosaic ~/Pictures/input.jpg mosaic.jpg ~/Pictures/*.jpg