Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

part7.html 4.9 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <?php header("Content-Type: text/html; charset=utf-8"); ?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
  3. "http://www.w3.org/TR/xhtml1/DTD/xhtml11.dtd">
  4. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  5. <head>
  6. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  7. <meta name="GENERATOR" content="vim" />
  8. <meta name="Author" content="sam@zoy.org (Sam Hocevar)" />
  9. <meta name="Description" content="Libcaca study - 7. Photographic mosaics" />
  10. <meta name="Keywords" content="libcaca, ASCII, ASCII ART, console, text mode, ncurses, slang, AAlib, dithering, thresholding" />
  11. <title>Libcaca study - 7. Photographic mosaics</title>
  12. <link rel="icon" type="image/x-icon" href="/favicon.ico" />
  13. <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
  14. <link rel="stylesheet" type="text/css" href="/main.css" />
  15. </head>
  16. <body>
  17. <?php include($_SERVER["DOCUMENT_ROOT"]."/header.inc"); ?>
  18. <p> <span style="color: #aa0000; font-weight: bold;">Warning</span>: this
  19. document is still work in progress. Feel free to send comments but do not
  20. consider it final material. </p>
  21. <div style="float: left;">
  22. <a href="part6.html">Colour dithering &lt;&lt;&lt;</a>
  23. </div>
  24. <div style="float: right;">
  25. <a href="biblio.html">&gt;&gt;&gt; Bibliography</a>
  26. </div>
  27. <div style="text-align: center;">
  28. <a href="index.html">^^^ Index</a>
  29. </div>
  30. <h2> 7. Photographic mosaics </h2>
  31. <p> Photographic mosaics are montages of smaller images creating the illusion
  32. of a bigger image. </p>
  33. <p> Since we don’t have many images at our disposal, we will simply cut Lena
  34. into small chunks (called <b>tiles</b>) and use these parts to create mosaics.
  35. This is our <b>tile database</b>: </p>
  36. <p style="text-align: center;">
  37. <img src="out/lena7-0-1.png" width="408" height="288"
  38. class="inline" alt="Patterns taken from Lena" />
  39. </p>
  40. <p> Generating a photomosaic consists in subdividing the original picture
  41. into <i>x</i> rectangular cells and find <i>x</i> tiles in the database
  42. (with or without duplicates, depending on the set of rules that is decided)
  43. so that when recombined the resulting image resembles the original picture.
  44. By the way, this technique is covered by Runaway Technology Inc.’s
  45. <a href="http://www.freepatentsonline.com/6137498.html">U.S. patent
  46. 6137498</a> [9]. </p>
  47. <p> Picking the right tile for the right cell in the grid is a very
  48. expensive and complicated operation. One of the biggest problems is the
  49. cost of a database lookup: comparing each tile area pixel-by-pixel
  50. is an O(N) operation where N is the size of the database. We can resort
  51. to <b>image classification</b> in order to speed up database lookups. </p>
  52. <h3> 7.1. Image classification </h3>
  53. <p> One of the simplest image classification techniques is the storage of
  54. each tile’s <b>average colour</b> into a separate database that is used for
  55. best match lookups. Of course, this computation should be gamma-corrected:
  56. </p>
  57. <p style="text-align: center;">
  58. <img src="out/lena7-1-1.png" width="168" height="120"
  59. class="inline" alt="1 feature extracted from Lena patterns" />
  60. </p>
  61. <p> When creating the mosaic, we then only need to check the average colour
  62. instead of comparing each pixel one by one. Below is the result of the
  63. technique applied on a portion of the Lena picture: </p>
  64. <p style="text-align: center;">
  65. <img src="out/lena7-1-2.png" width="80" height="80"
  66. class="inlinetop" alt="Lena (detail)" />
  67. <img src="out/lena7-1-3.png" width="416" height="416"
  68. class="inline" alt="Mosaic created from Lena’s detail" />
  69. </p>
  70. <p> Better results can be achieved by storing <b>four colour values</b>, one
  71. for each corner of the tile: </p>
  72. <p style="text-align: center;">
  73. <img src="out/lena7-1-4.png" width="248" height="176"
  74. class="inline" alt="4 features extracted from Lena patterns" />
  75. </p>
  76. <p> Having 12 values per tile (4 RGB triplets) is still a lot less than the
  77. original count of 3072 (for 32×32 tiles), and the results show clear
  78. improvement. For instance the feathers-hat frontier is now a lot smoother: </p>
  79. <p style="text-align: center;">
  80. <img src="out/lena7-1-2.png" width="80" height="80"
  81. class="inlinetop" alt="Lena (detail)" />
  82. <img src="out/lena7-1-5.png" width="416" height="416"
  83. class="inline" alt="Mosaic created from Lena’s detail" />
  84. </p>
  85. <h3> 7.2. Error diffusion </h3>
  86. <p> TODO </p>
  87. <h3> 7.3. Colour ASCII art </h3>
  88. <!--
  89. <p> We
  90. There are many ways to tackle the problem of colour ASCII art
  91. , also referred to as ANSI art,
  92. -->
  93. <p style="text-align: center;">
  94. <img src="fig7-3-1.png" width="395" height="196"
  95. class="matrix" alt="ASCII art tiles" />
  96. </p>
  97. <div style="float: left;">
  98. <a href="part6.html">Colour dithering &lt;&lt;&lt;</a>
  99. </div>
  100. <div style="float: right;">
  101. <a href="biblio.html">&gt;&gt;&gt; Bibliography</a>
  102. </div>
  103. <div style="text-align: center;">
  104. <a href="index.html">^^^ Index</a>
  105. </div>
  106. <?php $rev = '$Id$';
  107. include($_SERVER['DOCUMENT_ROOT'].'/footer.inc'); ?>
  108. </body>
  109. </html>