PatchWorks reassembles an image with many small images, (patches) creating a photo mosaic.
How it works is explained here.
If you encounter failures in this documentation or in the program itself, or you don't understand why an error message occured, or you just have a question...
Don't hesitate to e-mail me.
PatchWorks is available on www.caligamedia.de as source code and binary.
Patchworks is run from the Console.
In Windows: Start / Run, cmd, OK
Change to the directory where patchworks.exe is stored.
switches to D:\patchworks
Create a Database
At first, a (or a few) database has to be created.
patchworks -newdb [DBpath/]name [Resolution [y-Resolution [DPI]]]
patchworks -newdb myDB
Creates a database named "myDB" in the current directory (e.g. D:\patchworks\myDB )
As there was no resolution parameter given, default values are used.
Default values are 32*32 pixels. That's the size of the "patches" which are stored in this database.
DPI is not important and can be left. Default DPI is 100.
patchworks -newdb C:\myDB
Creates the database "myDB" on C:\myDB
patchworks -newdb myDB 50
Creates a database named "myDB" in the current directory.
The resolution of the patches is defined as 50*50 pixels.
The maximum resolution for patches is about 4000*4000 Pixel, but this is not really an serious limitation as patches bigger than 100*100 do not make sense.
patchworks -newdb myDB 40 30
Creates a database named "myDB" in the current directory.
The resolution of the patches is defined as 40*30 pixels.
As the patches are not square, a later created patchwork (in this example) will be stretched in a 4:3 ratio. To prevent this the source image can be scaled in y-direction on 133.3% (4/3).
Fill a Database with Pictures
To achieve appealing results, many images are needed. Some hundred, better some thousand.
If you don't have enough images, you might find the google image search useful. If the patches are not too big, (e.g. 32*32) perhaps you can even use the preview images.
In the current version only truecolor bitmaps (24bit BMP) can be used. Therefore JPGs or other formats have to be converted before they can be used. To speed this up you can use the batch conversion function of IrfanView (or another tool that does this job). Tip: as bitmaps consume much space it is a good idea to scale them down a bit while you convert them.
Now, if we got enough bitmaps, we can start. The Images are read and stored in the specified database. If the resolution of an image does not match the resolution specified in the database, it becomes scaled. (In the current version only downscale is supported, images that are too small will be ignored.)
patchworks -addDB [DBpath/]name path[/xxxx.bmp]
patchworks -addDB myDB myBMPs
Adds all bitmaps in the directory myBMPs to the database myDB.
patchworks -addDB C:\myDB C:\mypics\myBMPs
If the database or the image directory is not located in the current directory (e.g. D:\patchworks), paths have to be specified.
patchworks -addDB C:\myDB C:\mypics\myBMPs\holiday.bmp
If you don't want to add all images in a directory, simply specify the name of a single file.
Delete a Database
It doesn't make any sense, but you can delete a database...
Deleting single patches in a database is currently not supported.
patchworks -delDB [DBpath/]name [Force]
patchworks -delDB myDB
Deletes the database myDB. Eventually a path has to be given, of course.
patchworks -delDB myDB force
With the parameter "force" a confirmation question is suppressed. Useful for scripts.
Create a Patchwork
Finally! We create a patchwork. Required is a source image (truecolor bitmap) and at least one database. (max. 10)
The source image should not be too big. If the patches of the database are 32*32 pixels and the source image is 300*200, the resulting image will be 9600*6400 pixels.
patchworks source.bmp target.bmp TOLERANCE patchDB1 ... patchDB10
patchworks portrait.bmp patchwork.bmp 3.5 myDB
Rebuilds the source image "portrait.bmp" with the patches in the database "myDB" and saves the resulting image as "patchwork.bmp".
The tolerance parameter defines how much a patch can "missmatch" to be used anyway. If you specify 0, PatchWorks always uses the patch that matches best. The resulting image will then look very similar to the source image (if you stand a few steps away). But many patches will then repeat very often, the image will look a bit monotonous. The (not really sensible) Value 100 would allow all images in the database. If the database is not too big, the original motive will no more be recognizable.
Sensible values for the tolerance parameter are from 0.0 to 10.0. (Recommended: 5.0)
For inquisitive people: Internal, PatchWorks doesn't use a percentage but values from 0 to 765 (3*255). this value represents how much a patch missmatches (summed for all 3 channels) the pixel that has to be replaced. This means, the statement 0,135 would allow that one single color channel may differ about one counter. Two counters for 0,27 (on one channel, or one counter on two channels).
patchworks portrait.bmp patchwork.bmp 3.5 myDB myDB2 Holiday2004 Robots
Here, 4 databases are used to create a patchwork. (myDB, myDB2, Holiday2004, Robots)
The order / sequence in which the databases are specified may matter: If two patches in two databases match exactly in the same degree, the first specified database will be preferred. (Except, the patch in the preferred database has been used more often than the other one.)
Create a PseudoPatchwork
For this, only a source image is needed, no databases.
With a PseudoPatchwork you can estimate easily, how a patchwork will look like with a database of, for example, 1000 images.
For this, so to speak, a pseudo database is created, that simply consists of 1000 random colors. Thus, instead of images, monochrome surfaces are used as patches.
patchworks source.bmp target.bmp pseudo [Colorcount [Resolution [y-Resolution]]]
patchworks portrait.bmp patchwork.bmp pseudo 10000 5
10000 random colors are generated which are used as patches of 5*5 pixels.
Bigger patches don't make sense as there are no details in monochrome patches anyway...
patchworks portrait.bmp patchwork.bmp pseudo
As no values for the amount of colors and the resolution are given, default values are used:
100 random colors are generated which are used as patches of 32*32 pixels.
Planned for future versions:
- Support for more image formats. (using the SDL-Image-Library, www.libsdl.org)
- Delete single images in a database.
- Optinal statement how often a patch may be used at maximum.
- Improve Scale. (Upscale. in worst case with SDL ^^)
- Preserve output image aspect ratio for patches that are not square.
- Scale, truncate or fill patches when read.
- use DPI statements ;)
- complete Linux code
Version 1.0, 2004-01-29
First "completely" working Version. However buggy.
Version 1.5, 2004-02-29
- fixed many Bugs (mainly in _main_Console.c)
- deactivated menu option. (too much work to fix ;)
- improoved Patchwork creation quality
- improoved Patchwork creation speed a lot (thx alex :)
- added Tolerance parameter
- added some statistical output on Patchwork creation.
- added version tag to database index file