]> granicus.if.org Git - imagemagick/blob - www/source/thresholds.xml
(no commit message)
[imagemagick] / www / source / thresholds.xml
1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <!DOCTYPE thresholds [
3 <!ELEMENT thresholds (threshold)+>
4 <!ELEMENT threshold (description , levels)>
5 <!ELEMENT description (CDATA)>
6 <!ELEMENT levels (CDATA)>
7 <!ATTLIST threshold map ID #REQUIRED>
8 <!ATTLIST levels width CDATA #REQUIRED>
9 <!ATTLIST levels height CDATA #REQUIRED>
10 <!ATTLIST levels divisor CDATA #REQUIRED>
11 ]>
12 <!--
13   Threshold Maps for Ordered Posterized Dither
14
15   Each "<threshold>" element defines the map name, description, and an array
16   of "levels" used to provide the threshold map for ordered dithering and
17   digital halftoning.
18
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
22   The description is a english description of what the threshold map achieves
23   and is only used for 'listing' the maps.
24
25   The map itself is a rectangular array of integers or threshold "levels"
26   of the given "width" and "height" declared within the enclosing <levels>
27   element.  That is "width*height" integers or "levels" *must* be provided
28   within each map.
29
30   Each of the "levels" integer values (each value representing the threshold
31   intensity "level/divisor" at which that pixel is turned on.  The "levels"
32   integers given can be any postive integers between "0" and the "divisor",
33   excluding those limits.
34
35   The "divisor" not only defines the upper limit and threshold divisor for each
36   "level" but also the total number of pseudo-levels the threshold mapping
37   creates and fills with a dither pattern.  That is a ordered bitmap dither
38   of a pure greyscale gradient will use a maximum of "divisor" ordered bitmap
39   patterns, including the patterns with all the pixels 'on' and all the pixel
40   'off'. It may define less patterns than that, but the color channels will
41   be thresholded in units based on "divisor".
42
43   Alternatively for a multi-level posterization, ImageMagick inserts
44   "divisor-2" dither patterns (as defined by the threshold map) between each of
45   channel color level produced.
46
47   For example the map "o2x2" has a divisor of 5, which will define 3 bitmap
48   patterns plus the patterns with all pixels 'on' and 'off'.  A greyscale
49   gradient will thus have 5 distinct areas.
50 -->
51 <thresholds>
52
53 <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
54   Minimal Dither and Non-Dither Threshold Maps
55 -->
56   <threshold map="threshold" alias="1x1">
57     <description>Threshold Non-Dither</description>
58     <levels width="1" height="1" divisor="2">
59         1
60     </levels>
61   </threshold>
62
63   <threshold map="checks" alias="2x1">
64     <description>Checkerboard Dither</description>
65     <levels width="2" height="2" divisor="3">
66        1 2
67        2 1
68     </levels>
69   </threshold>
70
71 <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
72   Diffused Pixel Ordered Dither Patterns
73 -->
74   <threshold map="o2x2" alias="2x2">
75     <description>Ordered 2x2 Diffused Pixel</description>
76     <levels width="2" height="2" divisor="5">
77        1  3
78        4  2
79     </levels>
80   </threshold>
81
82   <threshold map="o3x3" alias="3x3">
83     <description>Ordered 4x4 Diffused Pixel</description>
84     <levels width="3" height="3" divisor="10">
85         3  7  4
86         6  1  9
87         2  8  5
88     </levels>
89   </threshold>
90
91   <threshold map="o4x4" alias="4x4">
92     <!--
93        From "Dithering Algorithms"
94        http://www.efg2.com/Lab/Library/ImageProcessing/DHALF.TXT
95      -->
96     <description>Ordered 4x4 Diffused Pixel</description>
97     <levels width="4" height="4" divisor="17">
98        1   9   3  11
99       13   5  15   7
100        4  12   2  10
101       16   8  14   6
102     </levels>
103   </threshold>
104
105   <threshold map="o8x8" alias="8x8">
106     <!-- Extracted from original 'OrderedDither()' Function -->
107     <description>Ordered 8x8 Diffused Pixel</description>
108     <levels width="8" height="8" divisor="65">
109          1  49  13  61   4  52  16  64
110         33  17  45  29  36  20  48  32
111          9  57   5  53  12  60   8  56
112         41  25  37  21  44  28  40  24
113          3  51  15  63   2  50  14  62
114         35  19  47  31  34  18  46  30
115         11  59   7  55  10  58   6  54
116         43  27  39  23  42  26  38  22
117     </levels>
118   </threshold>
119
120 <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
121   Halftones - Angled 45 degrees
122
123   Initially added to ImageMagick by Glenn Randers-Pehrson, IM v6.2.8-6,
124   modified to be more halftone-like by Anthony, IM v6.2.9-7 Larger halftone
125   patterns still needed to be added.
126 -->
127   <threshold map="h4x4a" alias="4x1">
128     <description>Halftone 4x4 (angled)</description>
129     <levels width="4" height="4" divisor="9">
130        4  2  7  5
131        3  1  8  6
132        7  5  4  2
133        8  6  3  1
134     </levels>
135   </threshold>
136
137   <threshold map="h6x6a" alias="6x1">
138     <description>Halftone 6x6 (angled)</description>
139     <levels width="6" height="6" divisor="19">
140        14  13  10   8   2   3
141        16  18  12   7   1   4
142        15  17  11   9   6   5
143         8   2   3  14  13  10
144         7   1   4  16  18  12
145         9   6   5  15  17  11
146     </levels>
147   </threshold>
148
149   <threshold map="h8x8a" alias="8x1">
150     <description>Halftone 8x8 (angled)</description>
151     <levels width="8" height="8" divisor="33">
152        13   7   8  14  17  21  22  18
153         6   1   3   9  28  31  29  23
154         5   2   4  10  27  32  30  24
155        16  12  11  15  20  26  25  19
156        17  21  22  18  13   7   8  14
157        28  31  29  23   6   1   3   9
158        27  32  30  24   5   2   4  10
159        20  26  25  19  16  12  11  15
160     </levels>
161   </threshold>
162
163 <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
164   Halftones - Orthogonally Aligned, or Un-angled
165
166   Initially added by Anthony Thyssen, IM v6.2.9-5 using techniques from
167   "Dithering & Halftoning" by Gernot Haffmann
168   http://www.fho-emden.de/~hoffmann/hilb010101.pdf
169 -->
170   <threshold map="h4x4o">
171     <description>Halftone 4x4 (orthogonal)</description>
172     <levels width="4" height="4" divisor="17">
173         7  13  11   4
174        12  16  14   8
175        10  15   6   2
176         5   9   3   1
177     </levels>
178   </threshold>
179
180   <threshold map="h6x6o">
181     <description>Halftone 6x6 (orthogonal)</description>
182     <levels width="6" height="6" divisor="37">
183         7  17  27  14   9   4
184        21  29  33  31  18  11
185        24  32  36  34  25  22
186        19  30  35  28  20  10
187         8  15  26  16   6   2
188         5  13  23  12   3   1
189     </levels>
190   </threshold>
191
192   <threshold map="h8x8o">
193     <description>Halftone 8x8 (orthogonal)</description>
194     <levels width="8" height="8" divisor="65">
195         7  21  33  43  36  19   9   4
196        16  27  51  55  49  29  14  11
197        31  47  57  61  59  45  35  23
198        41  53  60  64  62  52  40  38
199        37  44  58  63  56  46  30  22
200        15  28  48  54  50  26  17  10
201         8  18  34  42  32  20   6   2
202         5  13  25  39  24  12   3   1
203     </levels>
204   </threshold>
205
206   <threshold map="h16x16o">
207     <!--
208        Direct extract from "Dithering & Halftoning" by Gernot Haffmann.
209        This may need some fine tuning for symmetry of the halftone dots,
210        as it was a mathematically formulated pattern.
211     -->
212     <description>Halftone 16x16 (orthogonal)</description>
213     <levels width="16" height="16" divisor="257">
214         4  12  24  44  72 100 136 152 150 134  98  70  42  23  11   3
215         7  16  32  52  76 104 144 160 158 142 102  74  50  31  15   6
216        19  27  40  60  92 132 168 180 178 166 130  90  58  39  26  18
217        36  48  56  80 124 176 188 204 203 187 175 122  79  55  47  35
218        64  68  84 116 164 200 212 224 223 211 199 162 114  83  67  63
219        88  96 112 156 192 216 232 240 239 231 214 190 154 111  95  87
220       108 120 148 184 208 228 244 252 251 243 226 206 182 147 119 107
221       128 140 172 196 219 235 247 256 255 246 234 218 194 171 139 127
222       126 138 170 195 220 236 248 253 254 245 233 217 193 169 137 125
223       106 118 146 183 207 227 242 249 250 241 225 205 181 145 117 105
224        86  94 110 155 191 215 229 238 237 230 213 189 153 109  93  85
225        62  66  82 115 163 198 210 221 222 209 197 161 113  81  65  61
226        34  46  54  78 123 174 186 202 201 185 173 121  77  53  45  33
227        20  28  37  59  91 131 167 179 177 165 129  89  57  38  25  17
228         8  13  29  51  75 103 143 159 157 141 101  73  49  30  14   5
229         1   9  21  43  71  99 135 151 149 133  97  69  41  22  10   2
230     </levels>
231   </threshold>
232
233 <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
234   Special Purpose Dithers
235 -->
236
237 </thresholds>