PatchWorks

PatchWorks



What's Up?

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.


How To?

Run PatchWorks

Patchworks is run from the Console.
In Windows: Start / Run, cmd, OK
Change to the directory where patchworks.exe is stored.
Example:
d:
cd d:\patchworks
switches to D:\patchworks

Create a Database

At first, a (or a few) database has to be created.
Syntax:
patchworks -newdb [DBpath/]name [Resolution [y-Resolution [DPI]]]

Examples:
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.)
Syntax:
patchworks -addDB [DBpath/]name path[/xxxx.bmp]

Examples:
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.
Syntax:
patchworks -delDB [DBpath/]name [Force]

Examples:
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.
Syntax:
patchworks source.bmp target.bmp TOLERANCE patchDB1 ... patchDB10

Examples:
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.
Syntax:
patchworks source.bmp target.bmp pseudo [Colorcount [Resolution [y-Resolution]]]

Examples:
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.


Future

Planned for future versions:

Version History

Version 1.0, 2004-01-29

First "completely" working Version. However buggy.

Version 1.5, 2004-02-29