README.SLACKWARE 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  1. Metapixel 1.0.2
  2. ===============
  3. Metapixel is a program for generating photomosaics. It can generate
  4. classical photomosaics, in which the source image is viewed as a
  5. matrix of equally sized rectangles for each of which a matching image
  6. is substitued, as well as collage-style photomosaics, in which
  7. rectangular parts of the source image at arbitrary positions (i.e. not
  8. aligned to a matrix) are substituted by matching images.
  9. Installation
  10. ------------
  11. To compile Metapixel, you need, in addition to a C compiler, libpng,
  12. libjpeg, and giflib. To run the script for preparing constituent
  13. images, you will additionally need Perl. Most Linux distributions
  14. contain these software packages. On MacOS X, you can get them with
  15. Fink (http://fink.sourceforge.net/).
  16. Edit the first line of Makefile if you want to install Metapixel
  17. somewhere else than /usr/local. Then, type
  18. make
  19. If everything compiled fine, become root and type
  20. make install
  21. Configuring Metapixel
  22. ---------------------
  23. You can optionally create a file ".metapixelrc" in your home directory
  24. to store some settings which makes it easier to use Metapixel, since
  25. you won't have to use that many switches on the command line.
  26. A sample configuration file is included in the Metapixel distribution
  27. under the name "metapixelrc". See the section "The Configuration
  28. File" below for details. It is advisable to at least set the options
  29. "prepare-directory" and "library-directory".
  30. Preparing images
  31. ----------------
  32. Before (non-anti-mosaic) mosaics can be created, the constituent
  33. images need to be preprocessed. Preparing an image does two things.
  34. Firstly, it computes various coefficients by which the image can be
  35. matched against a part of a source image. Secondly, the image is
  36. scaled to a smaller size. Usually this will be the size you intend to
  37. use for it in the target image, but it can be any arbitrary size. It
  38. makes sense to scale your images to the maximum size that you will use
  39. for constituent images. That way, no information gets lost. The
  40. default size is 128x128 pixels. The matching data and the scaled
  41. images are stored in a directory which is then called a "library".
  42. You can use more than one library in the creation of a mosaic.
  43. To simplify the task of creating a library, the Perl script
  44. 'metapixel-prepare' is included in the distribution. It must be
  45. called with the name of the directory where your original images are
  46. stored in. As a second argument you must give the directory of the
  47. library to which the images are to be added. If you have set a
  48. default directory for preparing images in your configuration file,
  49. the second argument is optional.
  50. If the script is called with the option "--recurse", it searches the
  51. directory with the original images recursively, i.e., it searches all
  52. its direct and indirect subdirectories as well. It also accepts
  53. parameters specifying the size of the scaled down images. Just call
  54. it - it prints out usage information.
  55. If the script constantly complains that an error occurred when running
  56. 'metapixel', that probably means that metapixel is not in your path.
  57. The other possibility is that all your images are in a format that
  58. Metapixel doesn't like (it only supports JPEG, PNG, and GIF).
  59. Creating photomosaics
  60. ---------------------
  61. Input images for mosaics can have arbitrary sizes. Should you want
  62. the created mosaic to be of a different size than the input image, use
  63. the --scale option. It scales the input image uniformly in both
  64. directions (i.e. obeying the aspect ratio). If the width or height of
  65. the input image after scaling are not multiples of the width and
  66. height of the constituent images, the input image is further scaled up
  67. to the smallest size (larger than the input image) that obeys this
  68. constraint, possibly changing the aspect ratio a bit. This does not
  69. apply to collages, however. The sizes of their source images after
  70. scaling are always left untouched.
  71. Metapixel produces output images in the PNG or JPEG formats, depending
  72. on the extension of the output file name. In order to create a
  73. classic photomosaic for the image input.jpg and write the output to
  74. output.png with constituent images stored in the directory "images",
  75. use the following command line:
  76. metapixel --library images --metapixel input.jpg output.png
  77. To create a collage use
  78. metapixel --library images --collage --metapixel input.jpg output.png
  79. Using the -y, -i and -q options you can change the weights for each of
  80. the color channels. For example, to match only luminance, completely
  81. disregarding chrominance, use
  82. metapixel --library images -i0 -q0 --metapixel input.jpg output.png
  83. The default weight for each of the channels is 1.
  84. Using the --cheat option you can specify the percentage by which the
  85. resulting photomosaic should be overlayed by the original image. The
  86. default is 0, i.e., the photomosaic is not overlayed at all. A
  87. percentage of 100 yields, not surprisingly, the original image. A
  88. percentage of 30 makes the photomosaic appear noticably better but is
  89. yet small enough to go unnoticed without close inspection in most
  90. circumstances.
  91. As of version 0.6, Metapixel implements two different matching
  92. algorithms. The new metric, which is a trivial distance function,
  93. seems to give better results while not being slower than the old
  94. wavelet metric. The metric can be chosen using the --metric option.
  95. The default is the new subpixel metric.
  96. You can use the --library option more than once to let Metapixel use
  97. more than one library for a mosaic.
  98. Classic Mosaics
  99. ---------------
  100. Metapixel allows you to choose between two algorithms for finding
  101. matching images, via the --search option. The old algorithm called
  102. "local" simply selects the best matching image for each location,
  103. possibly disregarding images selected in locations nearby (see below).
  104. The new algorithm called "global" repeats the following step until all
  105. locations have been assigned to: Find the best match for any location
  106. among all small images that have not already been used. This
  107. guarantees that no small image is used twice. Obviously, it also
  108. means that you must have at least as many small images as there are
  109. locations in the image.
  110. Note that "global" is much slower and uses more memory than "local".
  111. The "--distance" option lets you specify the minimal distance between
  112. two occurences of the same constituent image in the target image for
  113. the "local" algorithm. Distance 0 means that it is allowed for the
  114. same image to occur in adjacent positions in the matrix. The default
  115. distance is 5, which means that there must be at least 5 images
  116. "between" two occurences of the same image in the matrix. Note that
  117. Metapixel is forced to select non-optimal matches for distances
  118. greater 0.
  119. Antimosaics
  120. -----------
  121. Antimosaics are classic mosaics for which the small images are the
  122. parts of a single image, possibly the input image itself, and can be
  123. created using the --antimosaic option. Metapixel subdivides the
  124. antimosaic file as if it were doing a mosaic of that file, but then
  125. uses the resulting subimages as the small images for a classic mosaic.
  126. In case the antimosaic image and the input image are the same,
  127. Metapixel will simply reconstruct the input image from the subimages,
  128. because they will always match best in their original locations. To
  129. tell Metapixel to do otherwise, you can use the
  130. --forbid-reconstruction option, which allows you to specify a minimum
  131. distance between the original location of a subimage and the location
  132. it has in the resulting mosaic.
  133. Here's how you create an antimosaic with a minimum reconstruction
  134. distance of 2:
  135. metapixel --library images -x input.jpg -f 2 --metapixel input.jpg output.png
  136. The Configuration File
  137. ----------------------
  138. The first thing Metapixel does is try to read the file ".metapixelrc"
  139. in your home directory. From this file, it reads default values for
  140. its settings, so that you don't have to give them on the command line
  141. each time you use Metapixel.
  142. In this configuration file, you can use the following directives:
  143. (prepare-directory <directory>)
  144. The library directory which metapixel-prepare should use by
  145. default. metapixel-prepare does not automatically create the
  146. directory if it doesn't exist, so make sure it does.
  147. (prepare-dimensions <width> <height>)
  148. The size metapixel-prepare should use for the small images.
  149. (library-directory <directory>)
  150. A library directory which Metapixel should use when creating
  151. mosaics. You can use this directive more than once.
  152. (small-image-dimensions <width> <height>)
  153. The dimensions of the small images Metapixel should use in
  154. mosaics.
  155. (yiq-weights <y> <i> <q>)
  156. The weights for the channels to be used in matching images.
  157. (metric <metric>)
  158. The metric Metapixel should use for matching images. This can
  159. either be "subpixel" or "wavelet".
  160. (search-method <method>)
  161. The search method for creating classic mosaics. This can either
  162. be "local" or "global".
  163. (minimum-classic-distance <dist>)
  164. The minimum distance between two occurences of the same image in
  165. classic mosaics with the local search method.
  166. (minimum-collage-distance <dist>)
  167. The minimum distance (in pixels) between two occurences of the
  168. same image in collage mosaics.
  169. (cheat-amount <perc>)
  170. The cheat amount in percent.
  171. (forbid-reconstruction-distance <dist>)
  172. The minimum distance between the position of subimage in the
  173. original image and its position in the output image in an
  174. antimosaic.
  175. Take a look at the file "metapixelrc" in the distribution. It gives
  176. examples for each of the directives discussed here.
  177. Collages
  178. --------
  179. To create a collage, you have to use the "--collage" option in
  180. addition to "--metapixel".
  181. You can also specify a minimum distance between two occurences of the
  182. same image, which is measured in pixels. The default value is 256.
  183. Use the "--distance" option to change it. Note that the distance is
  184. measured between the centers of the images, not their edges, i.e., a
  185. minimum distance of 10 means that the centers of two occurences of the
  186. same image must be at least 10 pixels apart. This will usually mean
  187. that they are allowed to overlap, unless you use very tiny small
  188. images.
  189. Note that Metapixel uses ridiculous amounts of memory for collage
  190. mosaics. To create a collage photomosaics of size 2048x2048 your
  191. machine should at least have 64MBytes RAM.
  192. Protocols
  193. ---------
  194. Metapixel can, in addition to producing a classical mosaic, write a
  195. file specifying which small images it put in each of the locations.
  196. This protocol file can then be used to reproduce the mosaic without
  197. doing the matching again, for example to experiment with different
  198. cheat amounts. The protocol also contains information on how good
  199. each small image matches the original location, so you can find out
  200. where the matches are good and where they aren't. You can also modify
  201. the protocol and let metapixel generate a mosaic which it wouldn't
  202. have matched itself, for whatever reason you might want to do this.
  203. Use the --out option to create a protocol and the --in option to
  204. reproduce a mosaic from a protocol. The protocol file is a LISP list
  205. with the following syntax:
  206. (mosaic (size <WIDTH> <HEIGHT>) (metapixels . <PIXELS>))
  207. <WIDTH> and <HEIGHT> are the number of small images in the mosaic
  208. across the width and height of the mosaic, respectively. <PIXELS> is
  209. a list containing lists with the following syntax:
  210. (<X> <Y> <W> <H> <FILENAME>)
  211. <X> and <Y> are the position of the small image. The upper left small
  212. image has coordinates (0,0), the lower right (<WIDTH>-1,<HEIGHT>-1).
  213. <W> and <H> must both be 1 in this version of Metapixel. <FILENAME> is
  214. the name of the small image file.
  215. A typical line in the protocol file looks like this:
  216. (30 23 1 1 "semiharmless.new/wallpaper07.jpg.png") ; 4792.000000
  217. The number at the end of the line is the matching score. The lower
  218. the score, the better the match. Note that the semicolon ';'
  219. introduces a comment which lasts ends with the end of the line, so the
  220. matching score is not part of the protocol syntax.
  221. The matching algorithms
  222. -----------------------
  223. The algorithm that does the image matching via wavelets is described
  224. in the paper 'Fast Multiresolution Image Querying' by Charles
  225. E. Jacobs, Adam Finkelstein and David H. Salesin.
  226. The new subpixel metric is very trivial. I suggest you consult the
  227. source if you are interested in it. The matching function is
  228. subpixel_compare().
  229. Sorting Images by Size or Aspect Ratio
  230. --------------------------------------
  231. Metapixel comes with a tool called `metapixel-sizesort' which sorts
  232. images by size or aspect ratio by moving them to directories
  233. containing only files with similar size or aspect ratio.
  234. An example: Let's say you have thousands of images in /my/images, and
  235. you want them sorted by aspect ratio and placed in /my/sorted/images.
  236. You can do this with this command:
  237. metapixel-sizesort --ratio=2 /my/images /my/sorted/images
  238. The option `2' to ratio tells metapixel-sizesort to put all those
  239. images together whose aspect ratios are the same with an accuracy of
  240. two places behind the comma. You might now have (among others) a
  241. directory called /my/sorted/images/ratio_0.79 which contains all
  242. images whose ratio between width and height is about 0.79.
  243. Upgrading from versions 0.8/0.9/0.10
  244. ------------------------------------
  245. Starting from release 0.11, Metapixel requires that the tables file is
  246. in the same directory as the small images described in that file. If
  247. your configuration is different, all you need to do is to make sure
  248. that all these files are in the same directory. You don't need to
  249. remove the paths in the tables file, as Metapixel does that
  250. automatically.
  251. Upgrading from versions 0.6/0.7
  252. -------------------------------
  253. The tables file format has changed in Metapixel 0.8, but you don't
  254. need to run 'metapixel-prepare' again. There's a program called
  255. 'convert' included in the distribution that does the job. Just tell
  256. it which size your small images are, give it the old tables file on
  257. stdin and it writes the new one on stdout.
  258. For example, if your small images are 128 pixels wide and 96 pixels
  259. high, go to the directory with the tables file (usually the directory
  260. where the small images are) and do
  261. convert --width=128 --height=96 <tables >tables.mxt
  262. Licence and Availability
  263. ------------------------
  264. Metapixel is free software distributed under the terms of the GPL.
  265. The file `COPYING' contains the text of the license.
  266. The source of Metapixel is available at the Metapixel homepage at
  267. http://www.complang.tuwien.ac.at/schani/metapixel/
  268. ---
  269. Mark Probst
  270. schani@complang.tuwien.ac.at