Changeset 2002


Ignore:
Timestamp:
Nov 17, 2007, 3:12:54 AM (14 years ago)
Author:
Sam Hocevar
Message:
  • Started section 5.2 (accounting for other dimensions).
Location:
www/study
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • www/study/part5.html

    r1979 r2002  
    3737depends on the output media even more than grayscale dithering. </p>
    3838
    39 <h3> Separate-space dithering </h3>
     39<h3> 5.1. Separate-space dithering </h3>
    4040
    4141<p> In some cases it is possible to perform three one-dimensional dithering
     
    6666</p>
    6767
     68<h3> 5.2. Accounting for other dimensions </h3>
     69
     70<p> The following patterns shows three ways to dither the same colour
     71using our 8-colour palette. The first one mixes black, yellow and white
     72pixels. The second one mixes red, green and cyan pixels. The last one
     73mixes red, green and magenta pixels. But they all visually blend to the
     74same colour: </p>
     75
     76<p style="text-align: center;">
     77  <img src="pat5-1-2.png" width="240" height="160"
     78       class="inline" alt="3 ways to dither the same colour" />
     79</p>
     80
    6881<div style="float: left;">
    6982   <a href="part4.html">Grayscale dithering &lt;&lt;&lt;</a>
  • www/study/study.py

    r1991 r2002  
    535535test501(lenna256, ERROR_FSTEIN, test42x).writePng("out5-1-2.png")
    536536
    537 # Pattern 5.1.2: red-green or red-yellow pattern?
     537# Pattern 5.1.2: different colours give the same result
    538538dest = Image((240, 160))
    539539for x in range(80):
    540540    for y in range(80):
    541         r = DITHER_BAYER44[(y / 4) % 4][(x / 4) % 4] > 11
     541        r = DITHER_BAYER44[(y / 4) % 4][(x / 4) % 4] > 7
    542542        g = DITHER_BAYER44[(y / 4) % 4][(x / 4) % 4] > 13
    543         dest.setRgb(x, y, r, 0, g)
     543        b = DITHER_BAYER44[(y / 4) % 4][(x / 4) % 4] > 7
     544        dest.setRgb(x, y, r, b, g)
    544545    for y in range(80, 160):
    545         r = DITHER_BAYER44[y % 4][x % 4] > 11
     546        r = DITHER_BAYER44[y % 4][x % 4] > 7
    546547        g = DITHER_BAYER44[y % 4][x % 4] > 13
    547         dest.setRgb(x, y, r, 0, g)
     548        b = DITHER_BAYER44[y % 4][x % 4] > 7
     549        dest.setRgb(x, y, r, b, g)
    548550for x in range(80, 160):
    549551    for y in range(80):
    550         r = DITHER_BAYER44[(y / 4 + 1) % 4][(x / 4 + 1) % 4] > 11
     552        r = DITHER_BAYER44[(y / 4) % 4][(x / 4 + 1) % 4] > 7
    551553        g = DITHER_BAYER44[(y / 4) % 4][(x / 4) % 4] > 13
    552         dest.setRgb(x, y, r, 0, g)
     554        b = DITHER_BAYER44[(y / 4) % 4][(x / 4) % 4] > 7
     555        dest.setRgb(x, y, r, b, g)
    553556    for y in range(80, 160):
    554         r = DITHER_BAYER44[(y + 1) % 4][(x + 1) % 4] > 11
     557        r = DITHER_BAYER44[y % 4][(x + 1) % 4] > 7
    555558        g = DITHER_BAYER44[y % 4][x % 4] > 13
    556         dest.setRgb(x, y, r, 0, g)
     559        b = DITHER_BAYER44[y % 4][x % 4] > 7
     560        dest.setRgb(x, y, r, b, g)
    557561for x in range(160, 240):
    558562    for y in range(80):
    559         r = DITHER_BAYER44[(y / 4) % 4][(x / 4 + 1) % 4] > 11
     563        r = DITHER_BAYER44[(y / 4 + 1) % 4][(x / 4 + 1) % 4] > 7
    560564        g = DITHER_BAYER44[(y / 4) % 4][(x / 4) % 4] > 13
    561         dest.setRgb(x, y, r, 0, g)
     565        b = DITHER_BAYER44[(y / 4 + 1) % 4][(x / 4) % 4] > 7
     566        dest.setRgb(x, y, r, b, g)
    562567    for y in range(80, 160):
    563         r = DITHER_BAYER44[y % 4][(x + 1) % 4] > 11
     568        r = DITHER_BAYER44[(y + 1) % 4][(x + 1) % 4] > 7
    564569        g = DITHER_BAYER44[y % 4][x % 4] > 13
    565         dest.setRgb(x, y, r, 0, g)
     570        b = DITHER_BAYER44[(y + 1) % 4][x % 4] > 7
     571        dest.setRgb(x, y, r, b, g)
    566572dest.writePng("pat5-1-2.png")
    567573
Note: See TracChangeset for help on using the changeset viewer.