Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Renamed prepare to metapixel-prepare, which is now a Perl script. Bugfixes.
- Loading branch information
Showing
10 changed files
with
627 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,27 @@ | ||
PREFIX = /usr/local | ||
INSTALL = install | ||
|
||
BINDIR = $(PREFIX)/bin | ||
|
||
#PROFILE = -pg | ||
|
||
LDOPTS = -L/usr/X11R6/lib $(PROFILE) | ||
CCOPTS = -I/usr/X11R6/include -I/usr/X11R6/include/X11 -Wall -O9 $(PROFILE) | ||
CC = gcc | ||
#LIBFFM = -lffm | ||
|
||
all : metapixel | ||
|
||
metapixel : metapixel.o vector.o rwpng.o getopt.o getopt1.o | ||
$(CC) $(LDOPTS) -o metapixel metapixel.o vector.o rwpng.o getopt.o getopt1.o -lpng $(LIBFFM) -lm -lMagick -lX11 -lz -lbz2 | ||
|
||
%.o : %.c | ||
$(CC) $(CCOPTS) -c $< | ||
|
||
install : metapixel | ||
$(INSTALL) -d $(BINDIR) | ||
$(INSTALL) metapixel $(BINDIR) | ||
$(INSTALL) metapixel-prepare $(BINDIR) | ||
|
||
clean : | ||
rm -f *.o metapixel *~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
Metapixel 0.1 | ||
============= | ||
|
||
Metapixel is a program for generating photomosaics. It can generate | ||
classical photomosaics, where the source image is viewed as a matrix | ||
of equally sized rectangles for each of which a matching image is | ||
substitued, as well as collage-style photomosaics, in which | ||
rectangular parts of the source image at arbitrary positions (i.e. not | ||
aligned to a matrix) are substitued by matching images. | ||
|
||
|
||
Installation | ||
------------ | ||
|
||
In order to compile Metapixel, you need ImageMagick and libpng | ||
installed at your system. To run the script for preparing constituent | ||
images, you will additionally need Perl. Most Linux distributions | ||
contain these software packages. | ||
|
||
Edit the first line of Makefile if you want to install Metapixel | ||
somewhere else than /usr/local. Then, type | ||
|
||
make | ||
|
||
If everything compiled fine, become root and type | ||
|
||
make install | ||
|
||
|
||
Preparing images | ||
---------------- | ||
|
||
Before mosaics can be created the constituent images need to be | ||
preprocessed. Preparing an image does two things. Firstly, it computes | ||
various coefficients by which the image can be matched against a part | ||
of a source image. Secondly, the image is scaled to size it will have | ||
in the target image. Note that this size must be equal for all | ||
constituent images and must be known in advance. The default size is | ||
64x64 pixels. | ||
|
||
To simplify the task of preparing images, the Perl script | ||
'metapixel-prepare' is included in the distribution. It must be called | ||
with two parameters: the name of directory in which the original | ||
images are stored and the name of the directory which the scaled down | ||
images and the table file should be stored. It also accepts parameters | ||
specifying the size of the scaled down images. Just call it - it | ||
prints out usage information. | ||
|
||
|
||
Creating photomosaics | ||
--------------------- | ||
|
||
In order to create a photomosaic for an image, it should be scaled to | ||
an appropriate size. For classic photomosaics, the width and height of | ||
the source image must be multiples of the widths and heights of the | ||
small constituent images, respectively. This restriction does not | ||
apply to collages, however. | ||
|
||
Metapixel produces output images in the PNG format. In order to create | ||
a classic photomosaic for the image input.jpg and write the output to | ||
output.png with constituent images stored in the directory images, use | ||
the following command line: | ||
|
||
metapixel --metapixel input.jpg output.png <images/tables | ||
|
||
To create a collage use | ||
|
||
metapixel --collage --metapixel input.jpg output.png <images/tables | ||
|
||
Using the -y, -i and -q parameters you can change the weights for each | ||
of the color channels. For example, to match only luminance, | ||
completely disregarding chrominance, use | ||
|
||
metapixel -i0 -q0 --metapixel input.jpg output.png <images/tables | ||
|
||
The default weight for each of the channels is 1. | ||
|
||
Note that Metapixel uses ridiculous amounts of main memory. To create | ||
photomosaics of size 2048x2048 your machine should at least have | ||
64MBytes RAM. | ||
|
||
|
||
Licence and Availability | ||
------------------------ | ||
|
||
Metapixel is distributed under the terms of the GPL. | ||
|
||
The source of Metapixel is available at the Metapixel homepage at | ||
|
||
http://www.complang.tuwien.ac.at/~schani/metapixel/ | ||
|
||
|
||
--- | ||
Mark Probst | ||
schani@complang.tuwien.ac.at |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
#!/usr/bin/perl | ||
|
||
# metapixel-prepare --- prepare images for metapixeling. | ||
|
||
# Copyright (C) 1999 Mark Probst | ||
|
||
# Author: Mark Probst <schani@complang.tuwien.ac.at> | ||
# Maintainer: Mark Probst <schani@complang.tuwien.ac.at> | ||
# Version: 0.1 | ||
|
||
# This program is free software; you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation; either version 2, or (at your option) | ||
# any later version. | ||
|
||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
|
||
# You should have received a copy of the GNU General Public License | ||
# along with this program; if not, you can either send email to this | ||
# program's maintainer or write to: The Free Software Foundation, | ||
# Inc.; 675 Massachusetts Avenue; Cambridge, MA 02139, USA. | ||
|
||
use strict; | ||
|
||
use Getopt::Long; | ||
use File::Basename; | ||
use IO::Handle; | ||
|
||
sub usage { | ||
print STDERR "Usage: $0 [OPTION]... <srcdir> <destdir> | ||
Prepares all images in <srcdir> for use as small images in | ||
photomosaics. The scaled versions and the table file are | ||
stored in <destdir>. | ||
--help display this help and exit | ||
--width=WIDTH specify width of small images | ||
--height=HEIGHT specify height of small images | ||
"; | ||
exit(1); | ||
} | ||
|
||
my $width; | ||
my $height; | ||
|
||
if (!GetOptions("help", \&usage, | ||
"width=i", \$width, | ||
"height=i", \$height)) { | ||
usage(); | ||
} | ||
|
||
my $opts; | ||
|
||
if ($width) { | ||
$opts = "--width=$width"; | ||
} | ||
if ($height) { | ||
$opts .= " --height=$height"; | ||
} | ||
|
||
if ($#ARGV != 1) { | ||
usage(); | ||
} | ||
|
||
my ($srcdir, $destdir) = @ARGV; | ||
|
||
if (! -d $srcdir || ! -r $srcdir) { | ||
print "$0: directory $srcdir does not exist or is unreadable\n"; | ||
exit(1); | ||
} | ||
|
||
if (! -d $destdir ) { | ||
print "$0: directory $destdir does not exist\n"; | ||
exit(1); | ||
} | ||
|
||
STDOUT->autoflush(1); | ||
|
||
foreach my $filename (glob("$srcdir/*")) { | ||
if (-f $filename && -r $filename) { | ||
my ($name, $path, $suffix) = fileparse($filename); | ||
`metapixel $opts --prepare $filename $destdir/$name$suffix.png $destdir/tables`; | ||
print "."; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters