thresholds.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <!DOCTYPE thresholds [
  3. <!ELEMENT thresholds (threshold)+>
  4. <!ATTLIST thresholds xmlns CDATA #FIXED ''>
  5. <!ELEMENT threshold (description,levels)>
  6. <!ATTLIST threshold xmlns CDATA #FIXED '' alias NMTOKEN #IMPLIED
  7. map NMTOKEN #REQUIRED>
  8. <!ELEMENT description (#PCDATA)>
  9. <!ATTLIST description xmlns CDATA #FIXED ''>
  10. <!ELEMENT levels (#PCDATA)>
  11. <!ATTLIST levels xmlns CDATA #FIXED '' divisor CDATA #REQUIRED
  12. height CDATA #REQUIRED width CDATA #REQUIRED>
  13. ]>
  14. <!--
  15. Threshold Maps for Ordered Posterized Dither
  16. Each "<threshold>" element defines the map name, description, and an array
  17. of "levels" used to provide the threshold map for ordered dithering and
  18. digital halftoning.
  19. The "alias" attribute provides a backward compatible name for this threshold
  20. map (pre-dating IM v6.2.9-6), and are deprecated.
  21. The description is a english description of what the threshold map achieves
  22. and is only used for 'listing' the maps.
  23. The map itself is a rectangular array of integers or threshold "levels"
  24. of the given "width" and "height" declared within the enclosing <levels>
  25. element. That is "width*height" integers or "levels" *must* be provided
  26. within each map.
  27. Each of the "levels" integer values (each value representing the threshold
  28. intensity "level/divisor" at which that pixel is turned on. The "levels"
  29. integers given can be any positive integers between "0" and the "divisor",
  30. excluding those limits.
  31. The "divisor" not only defines the upper limit and threshold divisor for each
  32. "level" but also the total number of pseudo-levels the threshold mapping
  33. creates and fills with a dither pattern. That is a ordered bitmap dither
  34. of a pure greyscale gradient will use a maximum of "divisor" ordered bitmap
  35. patterns, including the patterns with all the pixels 'on' and all the pixel
  36. 'off'. It may define less patterns than that, but the color channels will
  37. be thresholded in units based on "divisor".
  38. Alternatively for a multi-level posterization, ImageMagick inserts
  39. "divisor-2" dither patterns (as defined by the threshold map) between each of
  40. channel color level produced.
  41. For example the map "o2x2" has a divisor of 5, which will define 3 bitmap
  42. patterns plus the patterns with all pixels 'on' and 'off'. A greyscale
  43. gradient will thus have 5 distinct areas.
  44. -->
  45. <thresholds>
  46. <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  47. Minimal Dither and Non-Dither Threshold Maps
  48. -->
  49. <threshold map="threshold" alias="1x1">
  50. <description>Threshold 1x1 (non-dither)</description>
  51. <levels width="1" height="1" divisor="2">
  52. 1
  53. </levels>
  54. </threshold>
  55. <threshold map="checks" alias="2x1">
  56. <description>Checkerboard 2x1 (dither)</description>
  57. <levels width="2" height="2" divisor="3">
  58. 1 2
  59. 2 1
  60. </levels>
  61. </threshold>
  62. <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  63. (dispersed) Ordered Dither Patterns
  64. -->
  65. <threshold map="o2x2" alias="2x2">
  66. <description>Ordered 2x2 (dispersed)</description>
  67. <levels width="2" height="2" divisor="5">
  68. 1 3
  69. 4 2
  70. </levels>
  71. </threshold>
  72. <threshold map="o3x3" alias="3x3">
  73. <description>Ordered 3x3 (dispersed)</description>
  74. <levels width="3" height="3" divisor="10">
  75. 3 7 4
  76. 6 1 9
  77. 2 8 5
  78. </levels>
  79. </threshold>
  80. <threshold map="o4x4" alias="4x4">
  81. <!--
  82. From "Dithering Algorithms"
  83. http://www.efg2.com/Lab/Library/ImageProcessing/DHALF.TXT
  84. -->
  85. <description>Ordered 4x4 (dispersed)</description>
  86. <levels width="4" height="4" divisor="17">
  87. 1 9 3 11
  88. 13 5 15 7
  89. 4 12 2 10
  90. 16 8 14 6
  91. </levels>
  92. </threshold>
  93. <threshold map="o8x8" alias="8x8">
  94. <!-- Extracted from original 'OrderedDither()' Function -->
  95. <description>Ordered 8x8 (dispersed)</description>
  96. <levels width="8" height="8" divisor="65">
  97. 1 49 13 61 4 52 16 64
  98. 33 17 45 29 36 20 48 32
  99. 9 57 5 53 12 60 8 56
  100. 41 25 37 21 44 28 40 24
  101. 3 51 15 63 2 50 14 62
  102. 35 19 47 31 34 18 46 30
  103. 11 59 7 55 10 58 6 54
  104. 43 27 39 23 42 26 38 22
  105. </levels>
  106. </threshold>
  107. <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  108. Halftones - Angled 45 degrees
  109. Initially added to ImageMagick by Glenn Randers-Pehrson, IM v6.2.8-6,
  110. modified to be more symmetrical with intensity by Anthony, IM v6.2.9-7
  111. These patterns initially start as circles, but then form diamonds
  112. pattern at the 50% threshold level, before forming negated circles,
  113. as it approached the other threshold extreme.
  114. -->
  115. <threshold map="h4x4a" alias="4x1">
  116. <description>Halftone 4x4 (angled)</description>
  117. <levels width="4" height="4" divisor="9">
  118. 4 2 7 5
  119. 3 1 8 6
  120. 7 5 4 2
  121. 8 6 3 1
  122. </levels>
  123. </threshold>
  124. <threshold map="h6x6a" alias="6x1">
  125. <description>Halftone 6x6 (angled)</description>
  126. <levels width="6" height="6" divisor="19">
  127. 14 13 10 8 2 3
  128. 16 18 12 7 1 4
  129. 15 17 11 9 6 5
  130. 8 2 3 14 13 10
  131. 7 1 4 16 18 12
  132. 9 6 5 15 17 11
  133. </levels>
  134. </threshold>
  135. <threshold map="h8x8a" alias="8x1">
  136. <description>Halftone 8x8 (angled)</description>
  137. <levels width="8" height="8" divisor="33">
  138. 13 7 8 14 17 21 22 18
  139. 6 1 3 9 28 31 29 23
  140. 5 2 4 10 27 32 30 24
  141. 16 12 11 15 20 26 25 19
  142. 17 21 22 18 13 7 8 14
  143. 28 31 29 23 6 1 3 9
  144. 27 32 30 24 5 2 4 10
  145. 20 26 25 19 16 12 11 15
  146. </levels>
  147. </threshold>
  148. <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  149. Halftones - Orthogonally Aligned, or Un-angled
  150. Initially added by Anthony Thyssen, IM v6.2.9-5 using techniques from
  151. "Dithering & Halftoning" by Gernot Hoffmann
  152. http://www.fho-emden.de/~hoffmann/hilb010101.pdf
  153. These patterns initially start as circles, but then form square
  154. pattern at the 50% threshold level, before forming negated circles,
  155. as it approached the other threshold extreme.
  156. -->
  157. <threshold map="h4x4o">
  158. <description>Halftone 4x4 (orthogonal)</description>
  159. <levels width="4" height="4" divisor="17">
  160. 7 13 11 4
  161. 12 16 14 8
  162. 10 15 6 2
  163. 5 9 3 1
  164. </levels>
  165. </threshold>
  166. <threshold map="h6x6o">
  167. <description>Halftone 6x6 (orthogonal)</description>
  168. <levels width="6" height="6" divisor="37">
  169. 7 17 27 14 9 4
  170. 21 29 33 31 18 11
  171. 24 32 36 34 25 22
  172. 19 30 35 28 20 10
  173. 8 15 26 16 6 2
  174. 5 13 23 12 3 1
  175. </levels>
  176. </threshold>
  177. <threshold map="h8x8o">
  178. <description>Halftone 8x8 (orthogonal)</description>
  179. <levels width="8" height="8" divisor="65">
  180. 7 21 33 43 36 19 9 4
  181. 16 27 51 55 49 29 14 11
  182. 31 47 57 61 59 45 35 23
  183. 41 53 60 64 62 52 40 38
  184. 37 44 58 63 56 46 30 22
  185. 15 28 48 54 50 26 17 10
  186. 8 18 34 42 32 20 6 2
  187. 5 13 25 39 24 12 3 1
  188. </levels>
  189. </threshold>
  190. <threshold map="h16x16o">
  191. <!--
  192. Direct extract from "Dithering & Halftoning" by Gernot Hoffmann.
  193. This may need some fine tuning for symmetry of the halftone dots,
  194. as it was a mathematically formulated pattern.
  195. -->
  196. <description>Halftone 16x16 (orthogonal)</description>
  197. <levels width="16" height="16" divisor="257">
  198. 4 12 24 44 72 100 136 152 150 134 98 70 42 23 11 3
  199. 7 16 32 52 76 104 144 160 158 142 102 74 50 31 15 6
  200. 19 27 40 60 92 132 168 180 178 166 130 90 58 39 26 18
  201. 36 48 56 80 124 176 188 204 203 187 175 122 79 55 47 35
  202. 64 68 84 116 164 200 212 224 223 211 199 162 114 83 67 63
  203. 88 96 112 156 192 216 232 240 239 231 214 190 154 111 95 87
  204. 108 120 148 184 208 228 244 252 251 243 226 206 182 147 119 107
  205. 128 140 172 196 219 235 247 256 255 246 234 218 194 171 139 127
  206. 126 138 170 195 220 236 248 253 254 245 233 217 193 169 137 125
  207. 106 118 146 183 207 227 242 249 250 241 225 205 181 145 117 105
  208. 86 94 110 155 191 215 229 238 237 230 213 189 153 109 93 85
  209. 62 66 82 115 163 198 210 221 222 209 197 161 113 81 65 61
  210. 34 46 54 78 123 174 186 202 201 185 173 121 77 53 45 33
  211. 20 28 37 59 91 131 167 179 177 165 129 89 57 38 25 17
  212. 8 13 29 51 75 103 143 159 157 141 101 73 49 30 14 5
  213. 1 9 21 43 71 99 135 151 149 133 97 69 41 22 10 2
  214. </levels>
  215. </threshold>
  216. <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  217. Halftones - Orthogonally Expanding Circle Patterns
  218. Added by Glenn Randers-Pehrson, 4 Nov 2010, ImageMagick 6.6.5-6
  219. Rather than producing a diamond 50% threshold pattern, these
  220. continue to generate larger (overlapping) circles. They are
  221. more like a true halftone pattern formed by covering a surface
  222. with either pure white or pure black circular dots.
  223. WARNING: true halftone patterns only use true circles even in
  224. areas of highly varying intensity. Threshold dither patterns
  225. can generate distorted circles in such areas.
  226. -->
  227. <threshold map="c5x5b" alias="c5x5">
  228. <description>Circles 5x5 (black)</description>
  229. <levels width="5" height="5" divisor="26">
  230. 1 21 16 15 4
  231. 5 17 20 19 14
  232. 6 21 25 24 12
  233. 7 18 22 23 11
  234. 2 8 9 10 3
  235. </levels>
  236. </threshold>
  237. <threshold map="c5x5w">
  238. <description>Circles 5x5 (white)</description>
  239. <levels width="5" height="5" divisor="26">
  240. 25 21 10 11 22
  241. 20 9 6 7 12
  242. 19 5 1 2 13
  243. 18 8 4 3 14
  244. 24 17 16 15 23
  245. </levels>
  246. </threshold>
  247. <threshold map="c6x6b" alias="c6x6">
  248. <description>Circles 6x6 (black)</description>
  249. <levels width="6" height="6" divisor="37">
  250. 1 5 14 13 12 4
  251. 6 22 28 27 21 11
  252. 15 29 35 34 26 20
  253. 16 30 36 33 25 19
  254. 7 23 31 32 24 10
  255. 2 8 17 18 9 3
  256. </levels>
  257. </threshold>
  258. <threshold map="c6x6w">
  259. <description>Circles 6x6 (white)</description>
  260. <levels width="6" height="6" divisor="37">
  261. 36 32 23 24 25 33
  262. 31 15 9 10 16 26
  263. 22 8 2 3 11 17
  264. 21 7 1 4 12 18
  265. 30 14 6 5 13 27
  266. 35 29 20 19 28 34
  267. </levels>
  268. </threshold>
  269. <threshold map="c7x7b" alias="c7x7">
  270. <description>Circles 7x7 (black)</description>
  271. <levels width="7" height="7" divisor="50">
  272. 3 9 18 28 17 8 2
  273. 10 24 33 39 32 23 7
  274. 19 34 44 48 43 31 16
  275. 25 40 45 49 47 38 27
  276. 20 35 41 46 42 29 15
  277. 11 21 36 37 28 22 6
  278. 4 12 13 26 14 5 1
  279. </levels>
  280. </threshold>
  281. <threshold map="c7x7w">
  282. <description>Circles 7x7 (white)</description>
  283. <levels width="7" height="7" divisor="50">
  284. 47 41 32 22 33 42 48
  285. 40 26 17 11 18 27 43
  286. 31 16 6 2 7 19 34
  287. 25 10 5 1 3 12 23
  288. 30 15 9 4 8 20 35
  289. 39 29 14 13 21 28 44
  290. 46 38 37 24 36 45 49
  291. </levels>
  292. </threshold>
  293. <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  294. Special Purpose Dithers
  295. -->
  296. </thresholds>