| 1 |
<chapter> |
| 2 |
<title>Weaving for inkjet printers</title> |
| 3 |
|
| 4 |
|
| 5 |
<sect1> |
| 6 |
<title>Introduction</title> |
| 7 |
<para> |
| 8 |
The Epson Stylus Color/Photo printers don't have memory to print |
| 9 |
using all of the nozzles in the print head. For example, the |
| 10 |
Stylus Photo 700/EX has 32 nozzles. At 720 dpi, with an 8" wide |
| 11 |
image, a single line requires ((8 × 720 × 6) / 8) |
| 12 |
bytes, or 4320 bytes (because the Stylus Photo printers have 6 |
| 13 |
ink colors). To use 32 nozzles per color would require 138240 |
| 14 |
bytes. It's actually worse than that, though, because the |
| 15 |
nozzles are spaced 8 rows apart. Therefore, in order to store |
| 16 |
enough data to permit sending the page as a simple raster, the |
| 17 |
printer would require enough memory to store 256 rows, or |
| 18 |
1105920 bytes. Considering that the Photo EX can print 11" |
| 19 |
wide, we're looking at more like 1.5 MB. In fact, these |
| 20 |
printers are capable of 1440 dpi horizontal resolution. This |
| 21 |
would require 3 MB. The printers actually have 64K-256K. |
| 22 |
</para> |
| 23 |
<para> |
| 24 |
With the newer (740/750 and later) printers it's even worse, |
| 25 |
since these printers support multiple dot sizes; of course, the |
| 26 |
even newer 2880×720 printers don't help either. |
| 27 |
</para> |
| 28 |
<para> |
| 29 |
Older Epson printers had a mode called |
| 30 |
MicroWeave<superscript>™</superscript>. In this mode, the |
| 31 |
host fed the printer individual rows of dots, and the printer |
| 32 |
bundled them up and sent them to the print head in the correct |
| 33 |
order to achieve high quality. This MicroWeave mode still works |
| 34 |
in new printers, but in some cases the implementation is very |
| 35 |
minimal: the printer uses exactly one nozzle of each color (the |
| 36 |
first one). This makes printing extremely slow (more than 30 |
| 37 |
minutes for one 8.5×11" page), although the quality is |
| 38 |
extremely high with no visible banding whatsoever. It's not |
| 39 |
good for the print head, though, since no ink is flowing through |
| 40 |
the other nozzles. This leads to drying of ink and possible |
| 41 |
permanent damage to the print head. |
| 42 |
</para> |
| 43 |
<para> |
| 44 |
By the way, although the Epson manual says that microweave mode |
| 45 |
should be used at 720 dpi, 360 dpi continues to work in much the |
| 46 |
same way. At 360 dpi, data is fed to the printer one row at a |
| 47 |
time on all Epson printers. The pattern that the printer uses |
| 48 |
to print is very prone to banding. However, 360 dpi is |
| 49 |
inherently a low quality mode; if you're using it, presumably |
| 50 |
you don't much care about quality. It is possible to do |
| 51 |
microweave at 360 DPI, with significantly improved quality. |
| 52 |
</para> |
| 53 |
<para> |
| 54 |
Except for the Stylus Pro printers (5000, 5500, 7000, 7500, |
| 55 |
9000, 9500, and when it's released the 10000), which can do |
| 56 |
microweave at any resolution, printers from roughly the Stylus |
| 57 |
Color 600 and later do not have the capability to do MicroWeave |
| 58 |
correctly in many cases (some printers can do MicroWeave |
| 59 |
correctly at 720 DPI). Instead, the host must arrange the |
| 60 |
output in the order that it will be sent to the print head. |
| 61 |
This is a very complex process; the jets in the print head are |
| 62 |
spaced more than one row (1/720") apart, so we can't simply send |
| 63 |
consecutive rows of dots to the printer. Instead, we have to |
| 64 |
pass e. g. the first, ninth, 17th, 25th... rows in order for |
| 65 |
them to print in the correct position on the paper. This |
| 66 |
interleaving process is called "soft" weaving. |
| 67 |
</para> |
| 68 |
<para> |
| 69 |
This decision was probably made to save money on memory in the |
| 70 |
printer. It certainly makes the driver code far more |
| 71 |
complicated than it would be if the printer could arrange the |
| 72 |
output. Is that a bad thing? Usually this takes far less CPU |
| 73 |
time than the dithering process, and it does allow us more |
| 74 |
control over the printing process, e.g. to reduce banding. |
| 75 |
Conceivably, we could even use this ability to map out bad jets. |
| 76 |
</para> |
| 77 |
<para> |
| 78 |
Interestingly, apparently the Windows (and presumably Macintosh) |
| 79 |
drivers for most or all Epson printers still list a |
| 80 |
“microweave” mode. Experiments have demonstrated |
| 81 |
that this does not in fact use the “microweave” mode |
| 82 |
of the printer. Possibly it does nothing, or it uses a |
| 83 |
different weave pattern from what the |
| 84 |
“non-microweave” mode does. This is unnecessarily |
| 85 |
confusing, at least for people who write drivers who try to |
| 86 |
explain them to people who don't. |
| 87 |
</para> |
| 88 |
<para> |
| 89 |
What makes this interesting is that there are many different |
| 90 |
ways of of accomplishing this goal. The naive way would be to |
| 91 |
divide the image up into groups of 256 rows (for a printer with |
| 92 |
32 jets and a separation of 8 rows), and print all the mod8=0 |
| 93 |
rows in the first pass, mod8=1 rows in the second, and so forth. |
| 94 |
The problem with this approach is that the individual ink jets |
| 95 |
are not perfectly uniform; some emit slightly bigger or smaller |
| 96 |
drops than others. Since each group of 8 adjacent rows is |
| 97 |
printed with the same nozzle, that means that there will be |
| 98 |
distinct streaks of lighter and darker bands within the image (8 |
| 99 |
rows is 1/90", which is visible; 1/720" is not). Possibly worse |
| 100 |
is that these patterns will repeat every 256 rows. This creates |
| 101 |
banding patterns that are about 1/3" wide. |
| 102 |
</para> |
| 103 |
<para> |
| 104 |
So we have to do something to break up this patterning. |
| 105 |
</para> |
| 106 |
<para> |
| 107 |
Epson do not publish the weaving algorithms that they use in |
| 108 |
their bundled drivers. Indeed, their developer web site |
| 109 |
(http://www.ercipd.com/isv/edr_docs.htm) does not even describe |
| 110 |
how to do this weaving at all; it says that the only way to |
| 111 |
achieve 720 dpi is to use MicroWeave. It does note (correctly) |
| 112 |
that 1440 dpi horizontal can only be achieved by the driver |
| 113 |
(i. e. in software). The manual actually makes it fairly clear |
| 114 |
how to do this (it requires two passes with horizontal head |
| 115 |
movement between passes), and it is presumably possible to do |
| 116 |
this with MicroWeave. |
| 117 |
</para> |
| 118 |
<para> |
| 119 |
The information about how to do this is apparently available |
| 120 |
under non-disclosure agreement (NDA). It's actually easy enough |
| 121 |
to reverse engineer what's inside a print file with a simple |
| 122 |
Perl script, which is supplied with the Gutenprint distribution |
| 123 |
as tests/parse-escp2. In any event, we weren't particularly |
| 124 |
interested in the weaving patterns Epson used. There are many |
| 125 |
factors that go into choosing a good weaving pattern; we're |
| 126 |
learning them as we go along. Issues such as drying time |
| 127 |
(giving the ink a few seconds more or less to dry can have |
| 128 |
highly visible effects) affect the quality of the output. |
| 129 |
</para> |
| 130 |
<para> |
| 131 |
The Uniprint GhostScript driver has been able to do weaving for |
| 132 |
a long time. It uses patterns that must be specified for each |
| 133 |
choice of resolution and printer. We preferred an algorithmic |
| 134 |
approach that computes a weave pattern for any given choice of |
| 135 |
inputs. This obviously requires extensive testing; we developed |
| 136 |
a test suite specifically for this purpose. |
| 137 |
</para> |
| 138 |
</sect1> |
| 139 |
<sect1> |
| 140 |
<title>Weaving algorithms</title> |
| 141 |
<para> |
| 142 |
I considered a few algorithms to perform the weave. The first |
| 143 |
one I devised let me use only (jets − |
| 144 |
distance_between_jets + 1) nozzles, or 25. This is OK in |
| 145 |
principle, but it's slower than using all nozzles. By playing |
| 146 |
around with it some more, I came up with an algorithm that lets |
| 147 |
me use all of the nozzles, except near the top and bottom of the |
| 148 |
page. |
| 149 |
</para> |
| 150 |
<para> |
| 151 |
This still produces some banding, though. Even better quality |
| 152 |
can be achieved by using multiple nozzles on the same line. How |
| 153 |
do we do this? In 1440×720 mode, we're printing two |
| 154 |
output lines at the same vertical position. However, if we want |
| 155 |
four passes, we have to effectively print each line twice. |
| 156 |
Actually doing this would increase the density, so what we do is |
| 157 |
print half the dots on each pass. This produces near-perfect |
| 158 |
output, and it's far faster than using (pseudo) |
| 159 |
“MicroWeave”. |
| 160 |
</para> |
| 161 |
<para> |
| 162 |
Yet another complication is how to get near the top and bottom |
| 163 |
of the page. This algorithm lets us print to within one head |
| 164 |
width of the top of the page, and a bit more than one head width |
| 165 |
from the bottom. That leaves a lot of blank space. Doing the |
| 166 |
weave properly outside of this region is increasingly difficult |
| 167 |
as we get closer to the edge of the paper; in the interior |
| 168 |
region, any nozzle can print any line, but near the top and |
| 169 |
bottom edges, only some nozzles can print. We originally |
| 170 |
handled this by using the naive way mentioned above near the |
| 171 |
borders, and switching over to the high quality method in the |
| 172 |
interior. Unfortunately, this meant that the quality is quite |
| 173 |
visibly degraded near the top and bottom of the page. We have |
| 174 |
since devised better algorithms that allow printing to the |
| 175 |
extreme top and bottom of the region that can physically be |
| 176 |
printed, with only minimal loss of quality. |
| 177 |
</para> |
| 178 |
<para> |
| 179 |
Epson does not advertise that the printers can print at the very |
| 180 |
top of the page, although in practice most of them can. The |
| 181 |
quality is degraded to some degree, and we have observed that in |
| 182 |
some cases not all of the dots get printed. Epson may have |
| 183 |
decided that the degradation in quality is sufficient that |
| 184 |
printing in that region should not be allowed. That is a valid |
| 185 |
decision, although we have taken another approach. |
| 186 |
</para> |
| 187 |
<sect2> |
| 188 |
<title>Simple weaving algorithms</title> |
| 189 |
<para> |
| 190 |
The initial problem is to calculate the starting position of |
| 191 |
each pass; the row number of the printer's top jet when |
| 192 |
printing that pass. Since we assume the paper cannot be |
| 193 |
reverse-fed, the print head must, for each pass, start |
| 194 |
either further down the page than the previous pass or at |
| 195 |
the same position. Each pass's start point is therefore at |
| 196 |
a non-negative offset from the previous pass's start point. |
| 197 |
</para> |
| 198 |
<para> |
| 199 |
Once we have a formula for the starting row of each pass, we |
| 200 |
then turn that “inside out” to get a formula for |
| 201 |
the pass number containing each row. |
| 202 |
</para> |
| 203 |
<para> |
| 204 |
First, let's define how our printer works. We measure |
| 205 |
vertical position on the paper in “rows”; the |
| 206 |
resolution with which the printer can position the paper |
| 207 |
vertically. The print head contains J ink jets, which are |
| 208 |
spaced S rows apart. |
| 209 |
</para> |
| 210 |
<para> |
| 211 |
Consider a very simple case: we want to print a page as |
| 212 |
quickly as possible, and we mostly don't care how sparse the |
| 213 |
printing is, so long as it's fairly even. |
| 214 |
</para> |
| 215 |
<para> |
| 216 |
It's pretty obvious how to do this. We make one pass with |
| 217 |
the print head, printing J lines of data, each line S rows |
| 218 |
after the previous one. We then advance the paper by S |
| 219 |
× J rows and print the next row. For example, if J = |
| 220 |
7 and S = 4, this method can be illustrated like this: |
| 221 |
</para> |
| 222 |
<informalexample> |
| 223 |
<screen>pass number |
| 224 |
| row number-------> |
| 225 |
| | 111111111122222222223333333333444444444455555555556666666666 |
| 226 |
| 0123456789012345678901234567890123456789012345678901234567890123456789 |
| 227 |
0 *---*---*---*---*---*---* |
| 228 |
1 *---*---*---*---*---*---* |
| 229 |
2 \-----------------------/ *---*---*---*---*---*- |
| 230 |
7 jets \---/ |
| 231 |
4 rows offset from one jet to the next |
| 232 |
\---------------------------/ |
| 233 |
7*4=28 rows offset from one pass to the next</screen> |
| 234 |
</informalexample> |
| 235 |
<para> |
| 236 |
In these examples, the vertical axis can be thought of as the |
| 237 |
time axis, with the pass number shown at the left margin, |
| 238 |
while the row number runs horizontally. A |
| 239 |
<computeroutput>*</computeroutput> shows each row printed by a |
| 240 |
pass, and a row of <computeroutput>-</computeroutput> is used |
| 241 |
to link together the rows printed by one pass of the print |
| 242 |
head. The first pass is numbered |
| 243 |
<computeroutput>0</computeroutput> and starts at row 0. Each |
| 244 |
subsequent pass p starts at row p × S × J. Each |
| 245 |
pass prints J lines, each line being S rows after the previous |
| 246 |
one. (For ease of viewing this file on a standard terminal, |
| 247 |
I'm clipping the examples at column 80.) |
| 248 |
</para> |
| 249 |
<para> |
| 250 |
This method covers the whole page with lines printed evenly |
| 251 |
S rows apart. However, we want to fill in all the other |
| 252 |
rows with printing to get a full-density page (we're |
| 253 |
ignoring oversampling at this stage). Where we have |
| 254 |
previously printed a single pass, we'll now print a |
| 255 |
“pass block”: we print extra passes to fill in |
| 256 |
the empty rows. A naive implementation might look like |
| 257 |
this: |
| 258 |
</para> |
| 259 |
<informalexample> |
| 260 |
<screen>0 *---*---*---*---*---*---* |
| 261 |
1 *---*---*---*---*---*---* |
| 262 |
2 *---*---*---*---*---*---* |
| 263 |
3 *---*---*---*---*---*---* |
| 264 |
4 *---*---*---*---*---*---* |
| 265 |
5 *---*---*---*---*---*---* |
| 266 |
6 *---*---*---*---*---*---* |
| 267 |
7 *---*---*---*---*---*---* |
| 268 |
8 *---*---*---*---*---*- |
| 269 |
9 *---*---*---*---*---* |
| 270 |
10 *---*---*---*---*--- |
| 271 |
11 *---*---*---*---*--</screen> |
| 272 |
</informalexample> |
| 273 |
<para> |
| 274 |
(Now you can see why this process is called |
| 275 |
“weaving”!) |
| 276 |
</para> |
| 277 |
</sect2> |
| 278 |
<sect2> |
| 279 |
<title>Perfect weaving</title> |
| 280 |
<para> |
| 281 |
This simple weave pattern prints every row, but will give |
| 282 |
conspicuous banding patterns for the reasons discussed |
| 283 |
above. |
| 284 |
</para> |
| 285 |
<para> |
| 286 |
Let's start improving this for our simple case. We can |
| 287 |
reduce banding by making sure that any given jet never |
| 288 |
prints a row too close to another row printed by the same |
| 289 |
jet. This means we want to space the rows printed by a |
| 290 |
given jet evenly down the page. In turn, this implies we |
| 291 |
want to advance the paper by as nearly an equal amount after |
| 292 |
each pass as possible. |
| 293 |
</para> |
| 294 |
<para> |
| 295 |
Each pass block prints S × J lines in S passes. The |
| 296 |
first line printed in each pass block is S × J rows |
| 297 |
lower on the page than the first line printed in the |
| 298 |
previous pass block. Therefore, if we advance the paper by |
| 299 |
J rows between each pass, we can print the right number of |
| 300 |
passes in each block and advance the paper perfectly evenly. |
| 301 |
</para> |
| 302 |
<para> |
| 303 |
Here's what this “perfect” weave looks like: |
| 304 |
</para> |
| 305 |
<informalexample> |
| 306 |
<screen> start of full weave |
| 307 |
| |
| 308 |
0 *---*---*---*---*---*---* |
| 309 |
1 *---*---*---*---*---*---* |
| 310 |
2 *---*---*---*---*---*---* |
| 311 |
3 *---*---*---*---*---*---* |
| 312 |
4 *---*---*---*---*---*---* |
| 313 |
5 *---*---*---*---*---*---* |
| 314 |
6 *---*---*---*---*---*---* |
| 315 |
7 *---*---*---*---*---*---* |
| 316 |
8 *---*---*---*---*---*- |
| 317 |
9 *---*---*---*-- |
| 318 |
10 *---*--- |
| 319 |
11 *</screen> |
| 320 |
</informalexample> |
| 321 |
<para> |
| 322 |
You'll notice that, for the first few rows, this weave is |
| 323 |
too sparse. It is not until the row marked “start of |
| 324 |
full weave” that every subsequent row is printed. We |
| 325 |
can calculate this start position as follows: |
| 326 |
</para> |
| 327 |
<informalexample> |
| 328 |
<screen>start = (S − 1) × (J − 1)</screen> |
| 329 |
</informalexample> |
| 330 |
<para> |
| 331 |
For the moment, we will ignore this problem with the weave. |
| 332 |
We'll consider later how to fill in the missing rows. |
| 333 |
</para> |
| 334 |
<para> |
| 335 |
Let's look at a few more examples of perfect weaves: |
| 336 |
</para> |
| 337 |
<informalexample> |
| 338 |
<para> |
| 339 |
S = 2, J = 7, start = (2−1) × (7−1) = 6: |
| 340 |
</para> |
| 341 |
<screen> starting row of full weave |
| 342 |
| |
| 343 |
0 *-*-*-*-*-*-* |
| 344 |
1 *-*-*-*-*-*-* |
| 345 |
2 *-*-*-*-*-*-* |
| 346 |
3 *-*-*-*-*-*-* |
| 347 |
4 *-*-*-*-*-*-* |
| 348 |
5 *-*-*-*-*-*-* |
| 349 |
6 *-*-*-*-*-*-* |
| 350 |
7 *-*-*-*-*-*-*</screen> |
| 351 |
</informalexample> |
| 352 |
<informalexample> |
| 353 |
<para> |
| 354 |
S = 7, J = 2, start = 6: |
| 355 |
</para> |
| 356 |
<screen> start |
| 357 |
| |
| 358 |
0 *------* |
| 359 |
1 *------* |
| 360 |
2 *------* |
| 361 |
3 *------* |
| 362 |
4 *------* |
| 363 |
5 *------* |
| 364 |
6 *------* |
| 365 |
7 *------* |
| 366 |
8 *------* |
| 367 |
9 *------*</screen> |
| 368 |
</informalexample> |
| 369 |
<informalexample> |
| 370 |
<para> |
| 371 |
S = 4, J = 13, start = 36: |
| 372 |
</para> |
| 373 |
<screen> start |
| 374 |
| |
| 375 |
0 *---*---*---*---*---*---*---*---*---*---*---*---* |
| 376 |
1 *---*---*---*---*---*---*---*---*---*---*---*---* |
| 377 |
2 *---*---*---*---*---*---*---*---*---*---*---*---* |
| 378 |
3 *---*---*---*---*---*---*---*---*---*-- |
| 379 |
4 *---*---*---*---*---*---*- |
| 380 |
5 *---*---*---*</screen> |
| 381 |
</informalexample> |
| 382 |
<informalexample> |
| 383 |
<para> |
| 384 |
S = 13, J = 4, start = 36: |
| 385 |
</para> |
| 386 |
<screen> start |
| 387 |
| |
| 388 |
0 *------------*------------*------------* |
| 389 |
1 *------------*------------*------------* |
| 390 |
2 *------------*------------*------------* |
| 391 |
3 *------------*------------*------------* |
| 392 |
4 *------------*------------*------------* |
| 393 |
5 *------------*------------*------------* |
| 394 |
6 *------------*------------*------------* |
| 395 |
7 *------------*------------*------------* |
| 396 |
8 *------------*------------*------------* |
| 397 |
9 *------------*------------*------------* |
| 398 |
10 *------------*------------*----------- |
| 399 |
11 *------------*------------*------- |
| 400 |
12 *------------*------------*--- |
| 401 |
13 *------------*------------ |
| 402 |
14 *------------*-------- |
| 403 |
15 *------------*---- |
| 404 |
16 *------------* |
| 405 |
17 *--------- |
| 406 |
18 *----- |
| 407 |
19 *-</screen> |
| 408 |
</informalexample> |
| 409 |
<informalexample> |
| 410 |
<para> |
| 411 |
S = 8, J = 5, start = 28: |
| 412 |
</para> |
| 413 |
<screen> start |
| 414 |
| |
| 415 |
0 *-------*-------*-------*-------* |
| 416 |
1 *-------*-------*-------*-------* |
| 417 |
2 *-------*-------*-------*-------* |
| 418 |
3 *-------*-------*-------*-------* |
| 419 |
4 *-------*-------*-------*-------* |
| 420 |
5 *-------*-------*-------*-------* |
| 421 |
6 *-------*-------*-------*-------* |
| 422 |
7 *-------*-------*-------*-------* |
| 423 |
8 *-------*-------*-------*-------* |
| 424 |
9 *-------*-------*-------*-------* |
| 425 |
10 *-------*-------*-------*--- |
| 426 |
11 *-------*-------*------ |
| 427 |
12 *-------*-------*- |
| 428 |
13 *-------*---- |
| 429 |
14 *------- |
| 430 |
15 *--</screen> |
| 431 |
</informalexample> |
| 432 |
<informalexample> |
| 433 |
<para> |
| 434 |
S = 9, J = 5, start = 32: |
| 435 |
</para> |
| 436 |
<screen> start |
| 437 |
| |
| 438 |
0 *--------*--------*--------*--------* |
| 439 |
1 *--------*--------*--------*--------* |
| 440 |
2 *--------*--------*--------*--------* |
| 441 |
3 *--------*--------*--------*--------* |
| 442 |
4 *--------*--------*--------*--------* |
| 443 |
5 *--------*--------*--------*--------* |
| 444 |
6 *--------*--------*--------*--------* |
| 445 |
7 *--------*--------*--------*--------* |
| 446 |
8 *--------*--------*--------*--------* |
| 447 |
9 *--------*--------*--------*----- |
| 448 |
10 *--------*--------*--------* |
| 449 |
11 *--------*--------*---- |
| 450 |
12 *--------*-------- |
| 451 |
13 *--------*--- |
| 452 |
14 *------- |
| 453 |
15 *--</screen> |
| 454 |
</informalexample> |
| 455 |
<informalexample> |
| 456 |
<para> |
| 457 |
S = 6, J = 7, start = 30: |
| 458 |
</para> |
| 459 |
<screen> start |
| 460 |
| |
| 461 |
0 *-----*-----*-----*-----*-----*-----* |
| 462 |
1 *-----*-----*-----*-----*-----*-----* |
| 463 |
2 *-----*-----*-----*-----*-----*-----* |
| 464 |
3 *-----*-----*-----*-----*-----*-----* |
| 465 |
4 *-----*-----*-----*-----*-----*-----* |
| 466 |
5 *-----*-----*-----*-----*-----*-----* |
| 467 |
6 *-----*-----*-----*-----*-----*----- |
| 468 |
7 *-----*-----*-----*-----*---- |
| 469 |
8 *-----*-----*-----*--- |
| 470 |
9 *-----*-----*-- |
| 471 |
10 *-----*- |
| 472 |
11 *</screen> |
| 473 |
</informalexample> |
| 474 |
</sect2> |
| 475 |
<sect2> |
| 476 |
<title>Weaving collisions</title> |
| 477 |
<para> |
| 478 |
A perfect weave is not possible in all cases. Let's look at |
| 479 |
another example: |
| 480 |
</para> |
| 481 |
<informalexample> |
| 482 |
<para> |
| 483 |
S = 6, J = 4: |
| 484 |
</para> |
| 485 |
<screen>0 *-----*-----*-----* |
| 486 |
1 *-----*-----*-----* |
| 487 |
2 *-----*-----*-----* |
| 488 |
3 *-----*-----*-----* |
| 489 |
4 ^ *-^---*-----*-----* |
| 490 |
5 | ^ | *-^---*-----*-----* |
| 491 |
OUCH! ^ | ^ |
| 492 |
| |</screen> |
| 493 |
</informalexample> |
| 494 |
<para> |
| 495 |
Here we have a collision. Some lines printed in later |
| 496 |
passes overprint lines printed by earlier passes. We can |
| 497 |
see why by considering which row number is printed by a |
| 498 |
given jet number j (numbered from 0) of a given pass, p: |
| 499 |
</para> |
| 500 |
<informalexample> |
| 501 |
<screen>row(p, j) = (p × J) + (j × S)</screen> |
| 502 |
</informalexample> |
| 503 |
<para> |
| 504 |
Because J = 4 and S = 6 have a common factor of 2, jet 2 of |
| 505 |
pass 0 prints the same row as jet 0 of pass 3: |
| 506 |
</para> |
| 507 |
<informalexample> |
| 508 |
<screen>row(0, 2) = (0 × 4) + (2 × 6) = 12 |
| 509 |
row(3, 0) = (3 × 4) + (0 × 6) = 12</screen> |
| 510 |
</informalexample> |
| 511 |
<para> |
| 512 |
In fact, with this particular weave pattern, jets 0 and 1 of |
| 513 |
pass p + 3 always overprint jets 2 and 3 of pass p. We'll |
| 514 |
represent overprinting rows by a |
| 515 |
<computeroutput>^</computeroutput> in our diagrams, and |
| 516 |
correct rows by <computeroutput>*</computeroutput>: |
| 517 |
</para> |
| 518 |
<informalexample> |
| 519 |
<para> |
| 520 |
S = 6, J = 4: |
| 521 |
</para> |
| 522 |
<screen>0 *-----*-----*-----* |
| 523 |
1 *-----*-----*-----* |
| 524 |
2 *-----*-----*-----* |
| 525 |
3 ^-----^-----*-----* |
| 526 |
4 ^-----^-----*-----* |
| 527 |
5 ^-----^-----*-----*</screen> |
| 528 |
</informalexample> |
| 529 |
</sect2> |
| 530 |
<sect2> |
| 531 |
<title>What makes a “perfect” weave?</title> |
| 532 |
<para> |
| 533 |
So what causes the perfect weave cases to be perfect, and |
| 534 |
the other cases not to be? In all the perfect cases above, |
| 535 |
S and J are relatively prime (i.e. their greatest common |
| 536 |
divisor (GCD) is 1). As we mentioned above, S = 6 and J = 4 |
| 537 |
have a common factor, which causes the overprinting. Where |
| 538 |
S and J have a GCD of 1, they have no common factor other |
| 539 |
than 1 and, as a result, no overprinting occurs. If S and J |
| 540 |
are not relatively prime, their common factor will cause |
| 541 |
overprinting. |
| 542 |
</para> |
| 543 |
<para> |
| 544 |
We can work out the greatest common divisor of a pair of |
| 545 |
natural numbers using Euler's algorithm: |
| 546 |
</para> |
| 547 |
<orderedlist> |
| 548 |
<listitem> |
| 549 |
<para> |
| 550 |
Start with the two numbers: (e.g.) 9, 24 |
| 551 |
</para> |
| 552 |
</listitem> |
| 553 |
<listitem> |
| 554 |
<para> |
| 555 |
Swap them if necessary so that the larger one comes |
| 556 |
first: 24, 9 |
| 557 |
</para> |
| 558 |
</listitem> |
| 559 |
<listitem> |
| 560 |
<para> |
| 561 |
Subtract the second number from the first: 15, 9 |
| 562 |
</para> |
| 563 |
</listitem> |
| 564 |
<listitem> |
| 565 |
<para> |
| 566 |
Repeat until the first number becomes smaller: 6, 9 |
| 567 |
</para> |
| 568 |
</listitem> |
| 569 |
<listitem> |
| 570 |
<para> |
| 571 |
Swap the numbers again, so the larger one comes first: |
| 572 |
9, 6 |
| 573 |
</para> |
| 574 |
</listitem> |
| 575 |
<listitem> |
| 576 |
<para> |
| 577 |
Subtract again: 3, 6 |
| 578 |
</para> |
| 579 |
</listitem> |
| 580 |
<listitem> |
| 581 |
<para> |
| 582 |
Swap: 6, 3 |
| 583 |
</para> |
| 584 |
</listitem> |
| 585 |
<listitem> |
| 586 |
<para> |
| 587 |
Subtract: 3, 3 |
| 588 |
</para> |
| 589 |
</listitem> |
| 590 |
<listitem> |
| 591 |
<para> |
| 592 |
And again: 0, 3 |
| 593 |
</para> |
| 594 |
</listitem> |
| 595 |
<listitem> |
| 596 |
<para> |
| 597 |
When one of the numbers becomes 0, the other number is |
| 598 |
the GCD of the two numbers you started with. |
| 599 |
</para> |
| 600 |
</listitem> |
| 601 |
</orderedlist> |
| 602 |
<para> |
| 603 |
These repeated subtractions can be done with C's <literal>%</literal> |
| 604 |
operator, so we can write this in C as follows: |
| 605 |
</para> |
| 606 |
<informalexample> |
| 607 |
<programlisting>unsigned int |
| 608 |
gcd(unsigned int x, unsigned int y) |
| 609 |
{ |
| 610 |
if (y == 0) |
| 611 |
return x; |
| 612 |
while (x != 0) { |
| 613 |
if (y > x) |
| 614 |
swap (&x, &y); |
| 615 |
x %= y; |
| 616 |
} |
| 617 |
return y; |
| 618 |
}</programlisting> |
| 619 |
</informalexample> |
| 620 |
<para> |
| 621 |
<literal>gcd(S,J)</literal> will feature quite prominently in our |
| 622 |
weaving algorithm. |
| 623 |
</para> |
| 624 |
<para> |
| 625 |
If 0 ≤ j < J, there should only be a single pair (p, j) |
| 626 |
for any given row number. If S and J are not relatively |
| 627 |
prime, this assumption breaks down. (For conciseness, let G |
| 628 |
= GCD(S,J).) |
| 629 |
</para> |
| 630 |
<informalexample> |
| 631 |
<para> |
| 632 |
S = 8, J = 6, G = 2: |
| 633 |
</para> |
| 634 |
<screen>0 *-------*-------*-------*-------*-------* |
| 635 |
1 *-------*-------*-------*-------*-------* |
| 636 |
2 *-------*-------*-------*-------*-------* |
| 637 |
3 *-------*-------*-------*-------*-------* |
| 638 |
4 ^-------^-------^-------*-------*-------* |
| 639 |
5 ^-------^-------^-------*-------*-------*</screen> |
| 640 |
</informalexample> |
| 641 |
<para> |
| 642 |
In this case, jets 0, 1 and 2 of pass p + 4 collide with |
| 643 |
jets 3, 4 and 5 of pass p. |
| 644 |
</para> |
| 645 |
<para> |
| 646 |
How can we calculate these numbers? Suppose we were to |
| 647 |
print using fewer jets, say J / G jets. The greatest common |
| 648 |
divisor of J / G and S is 1, enabling a perfect weave. But |
| 649 |
to get a perfect weave, we also have to advance the paper by |
| 650 |
a factor of G less: |
| 651 |
</para> |
| 652 |
<informalexample> |
| 653 |
<screen>0 *-------*-------* - - - |
| 654 |
1 *-------*-------* - - - |
| 655 |
2 *-------*-------* - - - |
| 656 |
3 *-------*-------* - - - |
| 657 |
4 *-------*-------* - - - |
| 658 |
5 *-------*-------* - - -</screen> |
| 659 |
</informalexample> |
| 660 |
<para> |
| 661 |
If we left the paper advance alone, we'd get a sparse weave; |
| 662 |
only one row can be printed every G rows: |
| 663 |
</para> |
| 664 |
<informalexample> |
| 665 |
<screen>0 *-------*-------* - - - |
| 666 |
1 *-------*-------* - - - |
| 667 |
2 *-------*-------* - - - |
| 668 |
3 *-------*-------* - - - |
| 669 |
4 *-------*-------* - - - |
| 670 |
5 *-------*-------* - - - |
| 671 |
^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ |
| 672 |
These rows need filling in.</screen> |
| 673 |
</informalexample> |
| 674 |
<para> |
| 675 |
The rows that would have been printed by the jets we've now |
| 676 |
omitted (shown as <computeroutput>-</computeroutput>) are |
| 677 |
printed by other jets on later passes. |
| 678 |
</para> |
| 679 |
<para> |
| 680 |
Let's analyse this. Consider how a pass p could collide |
| 681 |
with pass 0. Pass p starts at offset p × J. Pass 0 |
| 682 |
prints at rows which are multiples of S. If p × J is |
| 683 |
exactly divisible by S, a collision has occurred, unless (p |
| 684 |
×J) ≥ J × S (which will happen when we |
| 685 |
finish a pass block). |
| 686 |
</para> |
| 687 |
<para> |
| 688 |
So, we want to find p and q such that p × J = q |
| 689 |
× S and p is minimised. Then p is the number of rows |
| 690 |
before a collision, and q is the number of jets in pass 0 |
| 691 |
which are not involved in the collision. To do this, we |
| 692 |
find the lowest common multiple of J and S, which is L = (J |
| 693 |
× S) / G. L / J is the number of rows before a |
| 694 |
collision, and L / S is the number of jets in the first pass |
| 695 |
not involved in the collision. |
| 696 |
</para> |
| 697 |
<para> |
| 698 |
Thus, we see that the first J / G rows printed by a given |
| 699 |
pass are not overprinted by any later pass. However, the |
| 700 |
rest of the rows printed by pass p are overprinted by the |
| 701 |
first J − (J / G) jets of pass p + (S / G). We will |
| 702 |
use C to refer to S / G, the number of rows after which a |
| 703 |
collision occurs. |
| 704 |
</para> |
| 705 |
<para> |
| 706 |
Another example: |
| 707 |
</para> |
| 708 |
<informalexample> |
| 709 |
<para> |
| 710 |
S = 6, J = 9, G = 3, C = S / G = 2: |
| 711 |
</para> |
| 712 |
<screen>0 *-----*-----*-----*-----*-----*-----*-----*-----* |
| 713 |
1 *-----*-----*-----*-----*-----*-----*-----*-----* |
| 714 |
2 ^-----^-----^-----^-----^-----^-----*-----*-----* |
| 715 |
3 ^-----^-----^-----^-----^-----^-----*-----*-----* |
| 716 |
4 ^-----^-----^-----^-----^-----^-----*----- |
| 717 |
5 ^-----^-----^-----^-----^-----^-- |
| 718 |
^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ ^^ |
| 719 |
These rows need filling in.</screen> |
| 720 |
</informalexample> |
| 721 |
<para> |
| 722 |
In this case, the first J − (J / G) = 9 − (9 / |
| 723 |
3) = 6 jets of pass p + (6 / 3) = p + 2 collide with the |
| 724 |
last 6 jets of pass p. Only one row in every G = 2 rows is |
| 725 |
printed by this weave. |
| 726 |
</para> |
| 727 |
<informalexample> |
| 728 |
<para> |
| 729 |
S = 9, J = 6, G = 3, C = 3: |
| 730 |
</para> |
| 731 |
<screen> |
| 732 |
0 *--------*--------*--------*--------*--------* |
| 733 |
1 *--------*--------*--------*--------*--------* |
| 734 |
2 *--------*--------*--------*--------*--------* |
| 735 |
3 ^--------^--------^--------^--------*--------* |
| 736 |
4 ^--------^--------^--------^--------*--------* |
| 737 |
5 ^--------^--------^--------^--------*--------*</screen> |
| 738 |
<para> |
| 739 |
Here, the first J - (J / G) = 6 - (6 / 3) = 4 jets of pass |
| 740 |
p + (9 / 3) = p + 3 collide with the last 4 jets of pass |
| 741 |
p. |
| 742 |
</para> |
| 743 |
<para> |
| 744 |
Note that, in these overprinting cases, only rows |
| 745 |
divisible by G are ever printed. The other rows, those |
| 746 |
not divisible by G, are not touched by this weave. |
| 747 |
</para> |
| 748 |
<para> |
| 749 |
We can modify our weave pattern to avoid overprinting any |
| 750 |
rows and simultaneously fill in the missing rows. Instead |
| 751 |
of using J alone to determine the start of each pass from |
| 752 |
the previous pass, we adjust the starting position of some |
| 753 |
passes. As mentioned before, we will divide the page into |
| 754 |
pass blocks, with S passes in each block. This ensures |
| 755 |
that the first jet of the first pass in a block prints the |
| 756 |
row which the Jth jet of the first pass of the previous |
| 757 |
block would have printed, if the print head had one extra |
| 758 |
jet. |
| 759 |
</para> |
| 760 |
<para> |
| 761 |
Looking back at an example of a perfect weave, we can |
| 762 |
divide it into pass blocks: |
| 763 |
</para> |
| 764 |
<informalexample> |
| 765 |
<para> |
| 766 |
S = 7, J = 2, G = 1: |
| 767 |
</para> |
| 768 |
<screen> imaginary extra jet |
| 769 |
| |
| 770 |
0 *------* * <--start of pass block 0 |
| 771 |
1 *------* | |
| 772 |
2 *------* | |
| 773 |
3 *------*| |
| 774 |
4 *-----|* |
| 775 |
5 *---|--* |
| 776 |
6 *-|----* |
| 777 |
| |
| 778 |
7 *------* <--start of pass block 1 |
| 779 |
8 *------* |
| 780 |
9 *------*</screen> |
| 781 |
</informalexample> |
| 782 |
<para> |
| 783 |
We can now calculate the start of a given pass by |
| 784 |
reference to its pass block. The first pass of pass block |
| 785 |
b always starts at row (b × S × J). The start |
| 786 |
row of each of the other passes in the block are |
| 787 |
calculated using offsets from this row. |
| 788 |
</para> |
| 789 |
<para> |
| 790 |
For the example above, there are 7 passes in each pass |
| 791 |
block, and their offsets are 0, 2, 4, 6, 8, 10 and 12. |
| 792 |
The next pass block is offset S × J = 14 rows from |
| 793 |
the start of the current pass block. |
| 794 |
</para> |
| 795 |
<para> |
| 796 |
The simplest way to modify the “perfect” weave |
| 797 |
pattern to give a correct weave in cases where G ≠ 1 |
| 798 |
is to simply change any offsets which would result in a |
| 799 |
collision, until the collision disappears. Every printed |
| 800 |
row in the weave, as we have shown it up to now, is |
| 801 |
separated from each of its neighbouring printed rows by G |
| 802 |
blank rows. We will add an extra offset to each colliding |
| 803 |
pass in such a way that we push the pass onto these |
| 804 |
otherwise blank rows. |
| 805 |
</para> |
| 806 |
<para> |
| 807 |
We have seen that, unless G = 1, the plain weave pattern |
| 808 |
results in each pass colliding with the pass S / G passes |
| 809 |
before. We will now subdivide our pass block into |
| 810 |
subblocks, each consisting of B = S / G passes. There are |
| 811 |
therefore G subblocks in a pass block. |
| 812 |
</para> |
| 813 |
<para> |
| 814 |
For each subblock, the passes in that subblock have a |
| 815 |
constant offset added to them. The offset is different |
| 816 |
for each subblock in a block. There are many ways we can |
| 817 |
choose the offsets, but the simplest is to make the offset |
| 818 |
equal to the subblock number (starting from 0). |
| 819 |
</para> |
| 820 |
<para> |
| 821 |
Thus, the passes in the first subblock in each pass block |
| 822 |
remain at the offsets we've already calculated from J. |
| 823 |
The passes in the second subblock each have 1 added to |
| 824 |
their offset, the passes in the third subblock have 2 |
| 825 |
added, and so on. Thus, the offset of pass p (numbered |
| 826 |
relative to the start of its pass block) is p × J + |
| 827 |
floor(p / B). |
| 828 |
</para> |
| 829 |
<para> |
| 830 |
This gives us a weave pattern looking like this: |
| 831 |
</para> |
| 832 |
<informalexample> |
| 833 |
<para> |
| 834 |
S = 6, J = 9, G = 3, B = 2: |
| 835 |
</para> |
| 836 |
<screen>0 *-----*-----*-----*-----*-----*-----*-----*-----* |
| 837 |
1 ^ *-----*-----*-----*-----*-----*-----*-----*-----* |
| 838 |
2 | +-> *-----*-----*-----*-----*-----*-----*-----*-----* |
| 839 |
3 | | *-----*-----*-----*-----*-----*-----*-----*-----* |
| 840 |
4 | | +-> *-----*-----*-----*-----*-----*-----*--- |
| 841 |
5 | | | *-----*-----*-----*-----*-----* |
| 842 |
6 | | | +-> *-----*-----*-----*----- |
| 843 |
7 | | | | *-----*-----*-- |
| 844 |
| | | start of pass block 1 |
| 845 |
| | | (offset returns to 0) |
| 846 |
| | start of subblock 2 (offset 2 rows) |
| 847 |
| start of subblock 1 (following passes offset by 1 row) |
| 848 |
start of passblock 0, subblock 0 (pass start calculated as p*J)</screen> |
| 849 |
</informalexample> |
| 850 |
<informalexample> |
| 851 |
<para> |
| 852 |
S = 9, J = 6, G = 3, B = 3: |
| 853 |
</para> |
| 854 |
<screen>0 *--------*--------*--------*--------*--------* |
| 855 |
1 *--------*--------*--------*--------*--------* |
| 856 |
2 *--------*--------*--------*--------*--------* |
| 857 |
3 *--------*--------*--------*--------*--------* |
| 858 |
4 *--------*--------*--------*--------*--------* |
| 859 |
5 *--------*--------*--------*--------*--------* |
| 860 |
6 *--------*--------*--------*--------*--- |
| 861 |
7 *--------*--------*--------*------ |
| 862 |
8 *--------*--------*--------* |
| 863 |
9 *--------*--------*----- |
| 864 |
10 \---/ *--------*-------- |
| 865 |
11 small offset *--------*-- |
| 866 |
12 *----</screen> |
| 867 |
</informalexample> |
| 868 |
<para> |
| 869 |
This method of choosing offsets for subblocks can result |
| 870 |
in an occasional small offset (as shown above) between one |
| 871 |
pass and the next, particularly when G is large compared |
| 872 |
to J. For example: |
| 873 |
</para> |
| 874 |
<informalexample> |
| 875 |
<para> |
| 876 |
S = 8, J = 4, G = 4, B = 2: |
| 877 |
</para> |
| 878 |
<screen>0 *-------*-------*-------* |
| 879 |
1 *-------*-------*-------* |
| 880 |
2 *-------*-------*-------* |
| 881 |
3 *-------*-------*-------* |
| 882 |
4 *-------*-------*-------* |
| 883 |
5 *-------*-------*-------* |
| 884 |
6 *-------*-------*-------* |
| 885 |
7 *-------*-------*-------* |
| 886 |
8 *-------*-------*-------* |
| 887 |
9 \/ *-------*-------*-------* |
| 888 |
very small offset!</screen> |
| 889 |
</informalexample> |
| 890 |
<para> |
| 891 |
We can plot the offset against the subblock number as |
| 892 |
follows: |
| 893 |
</para> |
| 894 |
<informalexample> |
| 895 |
<screen>subblock number |
| 896 |
| offset |
| 897 |
| | |
| 898 |
| 0123 |
| 899 |
0 * |
| 900 |
1 * |
| 901 |
2 * |
| 902 |
3 * |
| 903 |
0 * |
| 904 |
1 * |
| 905 |
2 * |
| 906 |
3 *</screen> |
| 907 |
</informalexample> |
| 908 |
<para> |
| 909 |
The discontinuity in this plot results in the small offset |
| 910 |
between passes. |
| 911 |
</para> |
| 912 |
<para> |
| 913 |
As we said at the beginning, we want the offsets from each |
| 914 |
pass to the next to be as similar as possible. We can fix |
| 915 |
this by calculating the offset for a given subblock b as |
| 916 |
follows: |
| 917 |
</para> |
| 918 |
<informalexample> |
| 919 |
<screen>offset(b) = 2*b , if b < ceiling(G/2) |
| 920 |
= 2*(G-b)-1 , otherwise</screen> |
| 921 |
</informalexample> |
| 922 |
<para> |
| 923 |
We can visualise this as follows, for G = 10: |
| 924 |
</para> |
| 925 |
<informalexample> |
| 926 |
<screen>0123456789 |
| 927 |
0 * |
| 928 |
1 * |
| 929 |
2 * |
| 930 |
3 * |
| 931 |
4 * |
| 932 |
5 * |
| 933 |
6 * |
| 934 |
7 * |
| 935 |
8 * |
| 936 |
9 * |
| 937 |
0 * |
| 938 |
1 * |
| 939 |
2 * |
| 940 |
3 * |
| 941 |
4 * |
| 942 |
5 * |
| 943 |
6 * |
| 944 |
7 * |
| 945 |
8 * |
| 946 |
9 *</screen> |
| 947 |
</informalexample> |
| 948 |
<para> |
| 949 |
and for G = 11: |
| 950 |
</para> |
| 951 |
<informalexample> |
| 952 |
<screen> 1 |
| 953 |
01234567890 |
| 954 |
0 * |
| 955 |
1 * |
| 956 |
2 * |
| 957 |
3 * |
| 958 |
4 * |
| 959 |
5 * |
| 960 |
6 * |
| 961 |
7 * |
| 962 |
8 * |
| 963 |
9 * |
| 964 |
10 * |
| 965 |
0 * |
| 966 |
1 * |
| 967 |
2 * |
| 968 |
3 * |
| 969 |
4 * |
| 970 |
5 * |
| 971 |
6 * |
| 972 |
7 * |
| 973 |
8 * |
| 974 |
9 * |
| 975 |
10 *</screen> |
| 976 |
</informalexample> |
| 977 |
<para> |
| 978 |
This gives a weave looking like this: |
| 979 |
</para> |
| 980 |
<informalexample> |
| 981 |
<para> |
| 982 |
S = 12, J = 6, G = 6, B = 2: |
| 983 |
</para> |
| 984 |
<screen>0 *-----------*-----------*-----------*-----------*-----------* |
| 985 |
1 *-----------*-----------*-----------*-----------*-----------* |
| 986 |
2 *-----------*-----------*-----------*-----------*-----------* |
| 987 |
3 *-----------*-----------*-----------*-----------*--------- |
| 988 |
4 *-----------*-----------*-----------*-----------*- |
| 989 |
5 *-----------*-----------*-----------*------- |
| 990 |
6 *-----------*-----------*-----------* |
| 991 |
7 *-----------*-----------*------ |
| 992 |
8 *-----------*-----------*-- |
| 993 |
9 *-----------*-------- |
| 994 |
10 *-----------*---- |
| 995 |
11 *---------- |
| 996 |
12 *-----</screen> |
| 997 |
</informalexample> |
| 998 |
<para> |
| 999 |
This method ensures that the offset between passes is |
| 1000 |
always in the range [J - 2, J + 2]. |
| 1001 |
</para> |
| 1002 |
<para> |
| 1003 |
(This might seem odd, but it occurs to me that a good |
| 1004 |
weave pattern might also make a good score for bell |
| 1005 |
ringers. When church bells are rung, a list of |
| 1006 |
“changes” are used. For example, if 8 bells |
| 1007 |
are being used, they will, at first, be rung in order: |
| 1008 |
12345678. If the first change is for bells 5 and 6, the |
| 1009 |
bells will then be rung in the order 12346578. If the |
| 1010 |
second change is 1 and 2, the next notes are 21346578. |
| 1011 |
After a long list of changes, the order the bells are rung |
| 1012 |
in can become quite complex. |
| 1013 |
</para> |
| 1014 |
<para> |
| 1015 |
For a group of bell-ringers to change the order of the |
| 1016 |
notes, they must each either delay their bell's next ring, |
| 1017 |
hasten it, or keep it the same as the time it takes to |
| 1018 |
ring all the bells once. The length of time between each |
| 1019 |
ring of a given bell can only be changed a little each |
| 1020 |
time, though; with an ink-jet weave pattern, we want the |
| 1021 |
same to apply to the distance between passes.) |
| 1022 |
</para> |
| 1023 |
<para> |
| 1024 |
Finally, knowing the number of jets J and their separation |
| 1025 |
S, we can calculate the starting row of any given pass p |
| 1026 |
as follows: |
| 1027 |
<informalexample> |
| 1028 |
<screen>passesperblock = S |
| 1029 |
passblock = floor(p / passesperblock) |
| 1030 |
offsetinpassblock = p - passblock * passesperblock |
| 1031 |
subblocksperblock = gcd(S, J) |
| 1032 |
passespersubblock = S / subblocksperblock |
| 1033 |
subpassblock = floor(offsetinpassblock / passespersubblock) |
| 1034 |
if subpassblock < ceiling(subblocksperblock/2) |
| 1035 |
subblockoffset = 2*subpassblock |
| 1036 |
else |
| 1037 |
subblockoffset = 2*(subblocksperblock-subpassblock)-1 |
| 1038 |
startingrow = passblock * S * J + offsetinpassblock * J + subblockoffset</screen> |
| 1039 |
</informalexample> |
| 1040 |
</para> |
| 1041 |
<para> |
| 1042 |
We can simplify this down to the following: |
| 1043 |
</para> |
| 1044 |
<informalexample> |
| 1045 |
<screen>subblocksperblock = gcd(S, J) |
| 1046 |
subpassblock = floor((p % S) * subblocksperblock / S) |
| 1047 |
if subpassblock * 2 < subblocksperblock |
| 1048 |
subblockoffset = 2*subpassblock |
| 1049 |
else |
| 1050 |
subblockoffset = 2*(subblocksperblock-subpassblock)-1 |
| 1051 |
startingrow = p * J + subblockoffset</screen> |
| 1052 |
</informalexample> |
| 1053 |
<para> |
| 1054 |
So the row number of jet j of pass p is |
| 1055 |
</para> |
| 1056 |
<informalexample> |
| 1057 |
<screen>subblocksperblock = gcd(S, J) |
| 1058 |
|
| 1059 |
subblockoffset(p) |
| 1060 |
= 2*subpassblock , if subpassblock * 2 < subblocksperblock |
| 1061 |
= 2*(subblocksperblock-subpassblock)-1 , otherwise |
| 1062 |
where |
| 1063 |
subpassblock = floor((p % S) * subblocksperblock / S) |
| 1064 |
|
| 1065 |
row(j, p) = p * J + subblockoffset(p) + j * S</screen> |
| 1066 |
</informalexample> |
| 1067 |
<para> |
| 1068 |
Together with the inequality 0 ≤ j < J, we can use |
| 1069 |
this definition in reverse to calculate the pass number |
| 1070 |
containing a given row, r. Working out the inverse |
| 1071 |
definition involves a little guesswork, but one possible |
| 1072 |
result is as follows. Given a row, r, which is known to |
| 1073 |
be the first row of a pass, we can calculate the pass |
| 1074 |
number as follows: |
| 1075 |
</para> |
| 1076 |
<informalexample> |
| 1077 |
<screen>subblocksperblock = gcd(S, J) |
| 1078 |
subblockoffset = r % subblocksperblock |
| 1079 |
pass = (r - subblockoffset) / J</screen> |
| 1080 |
</informalexample> |
| 1081 |
<para> |
| 1082 |
If G = 1, we can determine the pass number with this |
| 1083 |
algorithm: |
| 1084 |
</para> |
| 1085 |
<informalexample> |
| 1086 |
<screen>offset = r % J |
| 1087 |
pass = (r - offset) / J |
| 1088 |
while (offset % S != 0) |
| 1089 |
{ |
| 1090 |
pass-- |
| 1091 |
offset += J |
| 1092 |
} |
| 1093 |
jet = offset / S</screen> |
| 1094 |
</informalexample> |
| 1095 |
<para> |
| 1096 |
Generalising, we come up with this algorithm. Given r, S |
| 1097 |
and J: |
| 1098 |
</para> |
| 1099 |
<informalexample> |
| 1100 |
<screen>G = gcd(S, J) |
| 1101 |
passespersubblock = S/G |
| 1102 |
subblockoffset = r % G |
| 1103 |
subpassblock = subblockoffset / 2 , if subblockoffset % 2 == 0 |
| 1104 |
= G - (subblockoffset+1)/2 , otherwise |
| 1105 |
baserow = r - subblockoffset - (subpassblock * passespersubblock * J) |
| 1106 |
offset = baserow % J |
| 1107 |
pass = (baserow - offset) / J |
| 1108 |
while (offset % S != 0) |
| 1109 |
{ |
| 1110 |
offset += J |
| 1111 |
pass -= 1 |
| 1112 |
} |
| 1113 |
subblockretreat = floor(pass / passespersubblock) % G |
| 1114 |
pass -= subblockretreat * passespersubblock |
| 1115 |
pass += subpassblock * passespersubblock |
| 1116 |
jet = (r - subblockoffset - pass * J) / S</screen> |
| 1117 |
</informalexample> |
| 1118 |
<para> |
| 1119 |
Let's look at some examples of imperfect but correct weave |
| 1120 |
patterns: |
| 1121 |
</para> |
| 1122 |
<informalexample> |
| 1123 |
<para> |
| 1124 |
S = 6, J = 4, GCD = 2, |
| 1125 |
passesperblock = S = 6, |
| 1126 |
passespersubblock = S / G = 6 / 2 = 3: |
| 1127 |
</para> |
| 1128 |
<screen>0 *-----*-----*-----* |
| 1129 |
1 *-----*-----*-----* |
| 1130 |
2 *-----*-----*-----* |
| 1131 |
3 *-----*-----*-----* |
| 1132 |
4 *-----*-----*-----* |
| 1133 |
5 *-----*-----*-----* |
| 1134 |
6 *-----*-----*-----* |
| 1135 |
7 *-----*-----*-----* |
| 1136 |
8 *-----*-----*-----* |
| 1137 |
9 *-----*-----*-----* |
| 1138 |
10 *-----*-----*-----* |
| 1139 |
11 *-----*-----*-----* |
| 1140 |
12 *-----*-----*-----* |
| 1141 |
13 *-----*-----*-----* |
| 1142 |
14 *-----*-----*-----* |
| 1143 |
15 *-----*-----*---- |
| 1144 |
16 *-----*-----* |
| 1145 |
17 *-----*-- |
| 1146 |
18 *----- |
| 1147 |
19 *-</screen> |
| 1148 |
</informalexample> |
| 1149 |
<informalexample> |
| 1150 |
<para> |
| 1151 |
S = 8, J = 6, G = 2, |
| 1152 |
passesperblock = S = 8, |
| 1153 |
passespersubblock= S / G = 8 / 2 = 4: |
| 1154 |
</para> |
| 1155 |
<screen>0 *-------*-------*-------*-------*-------* |
| 1156 |
1 *-------*-------*-------*-------*-------* |
| 1157 |
2 *-------*-------*-------*-------*-------* |
| 1158 |
3 *-------*-------*-------*-------*-------* |
| 1159 |
4 *-------*-------*-------*-------*-------* |
| 1160 |
5 *-------*-------*-------*-------*-------* |
| 1161 |
6 *-------*-------*-------*-------*-------* |
| 1162 |
7 *-------*-------*-------*-------*-- |
| 1163 |
8 *-------*-------*-------*----- |
| 1164 |
9 *-------*-------*------- |
| 1165 |
10 *-------*-------*- |
| 1166 |
11 *-------*--- |
| 1167 |
12 *----</screen> |
| 1168 |
</informalexample> |
| 1169 |
<informalexample> |
| 1170 |
<para> |
| 1171 |
S = 6, J = 12, G = 6, |
| 1172 |
passesperblock = S = 6, |
| 1173 |
passespersubblock= S / G = 6 / 6 = 1: |
| 1174 |
</para> |
| 1175 |
<screen>0 *-----*-----*-----*-----*-----*-----*-----*-----*-----*-----*-----* |
| 1176 |
1 *-----*-----*-----*-----*-----*-----*-----*-----*-----*-----*--- |
| 1177 |
2 *-----*-----*-----*-----*-----*-----*-----*-----*- |
| 1178 |
3 *-----*-----*-----*-----*-----*-----* |
| 1179 |
4 *-----*-----*-----*-----*-- |
| 1180 |
5 *-----*-----*---- |
| 1181 |
6 *-----</screen> |
| 1182 |
</informalexample> |
| 1183 |
<para> |
| 1184 |
We have now solved the basic weaving problem. There are |
| 1185 |
two further refinements we need to consider: oversampling, |
| 1186 |
and filling in the missing rows at the start of the weave. |
| 1187 |
</para> |
| 1188 |
</informalexample> |
| 1189 |
</sect2> |
| 1190 |
<sect2> |
| 1191 |
<title>Oversampling</title> |
| 1192 |
<para> |
| 1193 |
By oversampling, we mean printing on the same row more than |
| 1194 |
once. There are two reasons for oversampling: to increase |
| 1195 |
the horizontal resolution of the printout and to reduce |
| 1196 |
banding. |
| 1197 |
</para> |
| 1198 |
<para> |
| 1199 |
Oversampling to increase horizontal resolution is necessary |
| 1200 |
because, although the printer might be able to position an |
| 1201 |
ink drop to, for example, 1/1440" horizontally, it may not |
| 1202 |
be able to lay down two such drops 1/1440" apart. If it can |
| 1203 |
print two drops 1/720" apart, 2x oversampling will be |
| 1204 |
necessary to get a 1/1440" horizontal resolution. If it can |
| 1205 |
only print two drops 1/360" apart, 4x oversampling will be |
| 1206 |
necessary for a 1/1440" horizontal resolution. The printer |
| 1207 |
enforces this “drop spacing” by only accepting |
| 1208 |
raster passes with a horizontal resolution matching the |
| 1209 |
spacing with which it can print dots, so we must print |
| 1210 |
passes at different horizontal positions if we are to obtain |
| 1211 |
a higher horizontal resolution. (Another reason it does |
| 1212 |
this may be to reduce the amount of memory needed in the |
| 1213 |
printer.) |
| 1214 |
</para> |
| 1215 |
<para> |
| 1216 |
Oversampling can also be done to decrease the banding |
| 1217 |
apparent in an image. By splitting a row into two or more |
| 1218 |
sets of dots (“lines”) and printing each line on |
| 1219 |
the same row, but with a different nozzle for each line, we |
| 1220 |
can get a smoother print. |
| 1221 |
</para> |
| 1222 |
<para> |
| 1223 |
To quantify these two kinds of oversampling, we'll introduce |
| 1224 |
two new constants: H shows how many different horizontal |
| 1225 |
offsets we want to print at (the “horizontal |
| 1226 |
oversampling”) while O shows how many times we want to |
| 1227 |
print each row, over and above the number of times necessary |
| 1228 |
for horizontal oversampling (the “extra |
| 1229 |
oversampling”). |
| 1230 |
</para> |
| 1231 |
<para> |
| 1232 |
It is necessary for all the lines printed by a given pass to |
| 1233 |
have the same horizontal offset, but there need not be any |
| 1234 |
relation between them in terms of extra oversampling. For |
| 1235 |
the moment, however, we will treat all oversampling as |
| 1236 |
potentially requiring this alignment; all lines in one pass |
| 1237 |
must be derived from the original row data in the same way. |
| 1238 |
Thus, we'll assume O = 1 for now. |
| 1239 |
</para> |
| 1240 |
<para> |
| 1241 |
So, how do we do this oversampling? In fact, it can be done |
| 1242 |
easily: advance the paper by a factor of H less between each |
| 1243 |
pass. We'll define a new variable, A, to show how much we |
| 1244 |
advance the paper between passes. Previously, we'd have |
| 1245 |
defined A = J; we now let A = J / H. This also affects our |
| 1246 |
pass blocks. Printing one pass block used to involve |
| 1247 |
advancing the paper S × J rows; it now advances the |
| 1248 |
paper (S×J) / H rows. We therefore name a group of H |
| 1249 |
pass blocks a “band”. Printing one band |
| 1250 |
involves advancing the paper S×J rows, as a pass |
| 1251 |
block did before. |
| 1252 |
</para> |
| 1253 |
<para> |
| 1254 |
To keep our weave pattern working correctly, so that |
| 1255 |
overprinting does not occur within a pass block, we also |
| 1256 |
have to redefine G as GCD(S,A). Here's an example of an |
| 1257 |
oversampled weave pattern: |
| 1258 |
</para> |
| 1259 |
<informalexample> |
| 1260 |
<para> |
| 1261 |
S = 4, J = 10, H = 2, A = J/H = 10/2 = 5, |
| 1262 |
G= GCD(4,5) = 1, |
| 1263 |
passesperblock = S = 4, |
| 1264 |
passespersubblock = S/G = 4/1 = 4: |
| 1265 |
</para> |
| 1266 |
<screen>0 *---*---*---*---*---*---*---*---*---* |
| 1267 |
1 *---*---*---*---*---*---*---*---*---* |
| 1268 |
2 *---*---*---*---*---*---*---*---*---* |
| 1269 |
3 *---*---*---*---*---*---*---*---*---* |
| 1270 |
4 *---*---*---*---*---*---*---*---*---* |
| 1271 |
5 *---*---*---*---*---*---*---*---*---* |
| 1272 |
6 *---*---*---*---*---*---*---*---*---* |
| 1273 |
7 *---*---*---*---*---*---*---*---*---* |
| 1274 |
8 *---*---*---*---*---*---*---*---*---* |
| 1275 |
9 *---*---*---*---*---*---*---*---* |
| 1276 |
10 *---*---*---*---*---*---*--- |
| 1277 |
11 *---*---*---*---*---*-- |
| 1278 |
12 *---*---*---*---*- |
| 1279 |
13 *---*---*---* |
| 1280 |
14 *---*--- |
| 1281 |
15 *--</screen> |
| 1282 |
</informalexample> |
| 1283 |
<para> |
| 1284 |
Now we have to determine which line is printed by each jet on |
| 1285 |
each pass. If we number each line generated as we split up a |
| 1286 |
row, we can use these numbers. We'll number the lines in our |
| 1287 |
diagram by replacing the <computeroutput>*</computeroutput>s |
| 1288 |
with integers in the range [0…H−1]. |
| 1289 |
</para> |
| 1290 |
<para> |
| 1291 |
Overprinting occurs once per pass block, so we can simply |
| 1292 |
print pass block 0 with line 0, pass block 1 with line 1, |
| 1293 |
pass block 2 with line 2, etc, wrapping to 0 when we've run |
| 1294 |
out of lines: |
| 1295 |
</para> |
| 1296 |
<informalexample> |
| 1297 |
<screen>0 0---0---0---0---0---0---0---0---0---0 |
| 1298 |
1 0---0---0---0---0---0---0---0---0---0 |
| 1299 |
2 0---0---0---0---0---0---0---0---0---0 |
| 1300 |
3 0---0---0---0---0---0---0---0---0---0 |
| 1301 |
4 1---1---1---1---1---1---1---1---1---1 |
| 1302 |
5 1---1---1---1---1---1---1---1---1---1 |
| 1303 |
6 1---1---1---1---1---1---1---1---1---1 |
| 1304 |
7 1---1---1---1---1---1---1---1---1---1 |
| 1305 |
8 0---0---0---0---0---0---0---0---0---0 |
| 1306 |
9 0---0---0---0---0---0---0---0---0 |
| 1307 |
10 0---0---0---0---0---0---0--- |
| 1308 |
11 0---0---0---0---0---0-- |
| 1309 |
12 1---1---1---1---1- |
| 1310 |
13 1---1---1---1 |
| 1311 |
14 1---1--- |
| 1312 |
15 1--</screen> |
| 1313 |
</informalexample> |
| 1314 |
<informalexample> |
| 1315 |
<para> |
| 1316 |
S = 4, J = 12, H = 2, A = J/H = 12/2 = 6, |
| 1317 |
G= GCD(4,6) = 2, |
| 1318 |
passesperblock= S = 4, |
| 1319 |
passespersubblock= S/G = 4/2 = 2: |
| 1320 |
</para> |
| 1321 |
<screen>0 0---0---0---0---0---0---0---0---0---0---0---0 |
| 1322 |
1 0---0---0---0---0---0---0---0---0---0---0---0 |
| 1323 |
2 0---0---0---0---0---0---0---0---0---0---0---0 |
| 1324 |
3 0---0---0---0---0---0---0---0---0---0---0---0 |
| 1325 |
4 1---1---1---1---1---1---1---1---1---1---1---1 |
| 1326 |
5 1---1---1---1---1---1---1---1---1---1---1---1 |
| 1327 |
6 1---1---1---1---1---1---1---1---1---1---1 |
| 1328 |
7 1---1---1---1---1---1---1---1---1-- |
| 1329 |
8 0---0---0---0---0---0---0---0- |
| 1330 |
9 0---0---0---0---0---0--- |
| 1331 |
10 0---0---0---0---0 |
| 1332 |
11 0---0---0-- |
| 1333 |
12 1---1-</screen> |
| 1334 |
</informalexample> |
| 1335 |
<para> |
| 1336 |
But what do we do if J is not an exact multiple of H? This |
| 1337 |
is a difficult problem, which I struggled with for quite a |
| 1338 |
few days before giving in and taking the easy (but less |
| 1339 |
elegant) way out. The easy solution is to round J / H down, |
| 1340 |
then add on the accumulated error at the end of each band. |
| 1341 |
</para> |
| 1342 |
<informalexample> |
| 1343 |
<para> |
| 1344 |
S = 4, J = 11, H = 2, A = floor(J/H) = floor(11/2) = 5, |
| 1345 |
G = GCD(4,5) = 1, |
| 1346 |
passesperblock = S = 4, |
| 1347 |
passespersubblock = S/G = 4/1 = 4 |
| 1348 |
</para> |
| 1349 |
<screen>Band 0: |
| 1350 |
0 0---0---0---0---0---0---0---0---0---0---0 |
| 1351 |
1 0---0---0---0---0---0---0---0---0---0---0 |
| 1352 |
2 0---0---0---0---0---0---0---0---0---0---0 |
| 1353 |
3 0---0---0---0---0---0---0---0---0---0---0 |
| 1354 |
4 1---1---1---1---1---1---1---1---1---1---1 |
| 1355 |
5 1---1---1---1---1---1---1---1---1---1---1 |
| 1356 |
6 1---1---1---1---1---1---1---1---1---1---1 |
| 1357 |
7 1---1---1---1---1---1---1---1---1---1--- |
| 1358 |
|
| 1359 |
Band 1: |
| 1360 |
8 | 0---0---0---0---0---0---0---0---0- |
| 1361 |
9 \-----------------------------------------/ 0---0---0---0---0---0---0---0 |
| 1362 |
10 S*J rows 0---0---0---0---0---0--- |
| 1363 |
11 0---0---0---0---0-- |
| 1364 |
12 1---1---1---1- |
| 1365 |
13 1---1---1 |
| 1366 |
14 1---</screen> |
| 1367 |
</informalexample> |
| 1368 |
<para> |
| 1369 |
We can calculate the starting row and subpass number of a |
| 1370 |
given pass in this scheme as follows: |
| 1371 |
</para> |
| 1372 |
<informalexample> |
| 1373 |
<screen>A = floor(J / H) |
| 1374 |
subblocksperblock = gcd(S, A) |
| 1375 |
subpassblock = floor((p % S) * subblocksperblock / S) |
| 1376 |
if subpassblock * 2 < subblocksperblock |
| 1377 |
subblockoffset = 2*subpassblock |
| 1378 |
else |
| 1379 |
subblockoffset = 2*(subblocksperblock-subpassblock)-1 |
| 1380 |
band = floor(P / (S * H)) |
| 1381 |
passinband = P % (S * H) |
| 1382 |
startingrow = band * S * J + passinband * A + subblockoffset |
| 1383 |
subpass = passinband / S</screen> |
| 1384 |
</informalexample> |
| 1385 |
<para> |
| 1386 |
So the row number of jet j of pass p is |
| 1387 |
<informalexample> |
| 1388 |
<screen>A = floor(J / H) |
| 1389 |
subblocksperblock = gcd(S, A) |
| 1390 |
|
| 1391 |
subblockoffset(p) |
| 1392 |
= 2*subpassblock , if subpassblock * 2 < subblocksperblock |
| 1393 |
= 2*(subblocksperblock-subpassblock)-1 , otherwise |
| 1394 |
where |
| 1395 |
subpassblock = floor((p % S) * subblocksperblock / S) |
| 1396 |
|
| 1397 |
band(p) = floor(p / (S * H)) |
| 1398 |
passinband(p) = p % (S * H) |
| 1399 |
|
| 1400 |
row(j, p) = band(p) * S * J + passinband(p) * A + subblockoffset(p) + j * S |
| 1401 |
row(j, p) = p * J + subblockoffset(p) + j * S</screen> |
| 1402 |
<para> |
| 1403 |
To be continued… |
| 1404 |
</para> |
| 1405 |
</informalexample> |
| 1406 |
</para> |
| 1407 |
</sect2> |
| 1408 |
</sect1> |
| 1409 |
</chapter> |