Changeset 1937 for www


Ignore:
Timestamp:
Nov 11, 2007, 10:16:15 PM (13 years ago)
Author:
Sam Hocevar
Message:
  • Burkes dithering.
Location:
www/study
Files:
4 added
2 edited

Legend:

Unmodified
Added
Removed
  • www/study/index.html

    r1936 r1937  
    337337</p>
    338338
    339 <p> Finally, <b>Stucki dithering</b> is a slight variation of
    340 Jarvis-Judice-Ninke dithering: </p>
     339<p> <b>Stucki dithering</b> is a slight variation of Jarvis-Judice-Ninke
     340dithering: </p>
    341341
    342342<p style="text-align: center;">
     
    347347  <img src="grad3-2-3.png" width="32" height="256"
    348348       class="inline" alt="Stucki error diffusion gradient" />
     349</p>
     350
     351<p> <b>Burkes dithering</b> is yet another variation: </p>
     352
     353<p style="text-align: center;">
     354  <img src="fig3-2-4.png" width="200" height="120"
     355       style="margin-right: 30px;" alt="Burkes" />
     356  <img src="out3-2-4.png" width="256" height="256"
     357       class="inline" alt="Burkes error diffusion" />
     358  <img src="grad3-2-4.png" width="32" height="256"
     359       class="inline" alt="Burkes error diffusion gradient" />
    349360</p>
    350361
  • www/study/study.py

    r1936 r1937  
    346346
    347347# Output 3-2-3: Stucki
    348 # TODO: merge with Jarvis, Judice and Ninke
     348# TODO: merge with Jarvis-Judice-Ninke
    349349def test323(src, name):
    350350    (w, h) = src.size()
     
    379379test323(lenna256bw, "out3-2-3.png")
    380380test323(gradient256bw, "grad3-2-3.png")
     381
     382# Output 3-2-4: Burkes
     383# TODO: merge with Jarvis-Judice-Ninke and Stucki
     384def test324(src, name):
     385    (w, h) = src.size()
     386    dest = Image((w, h))
     387    ep = [0.] * (w + 4)
     388    for y in range(h):
     389        ey = [0.] * (w + 4)
     390        ex = 0
     391        ex2 = 0
     392        for x in range(w):
     393            c = src.getGray(x, y) + ex + ep[x + 2]
     394            d = c > 0.5
     395            dest.setGray(x, y, d)
     396            error = c - d
     397            ex = ex2 + error * 8. / 32.
     398            ex2 = error * 4. / 32.
     399            ey[x] += error * 2. / 32.
     400            ey[x + 1] += error * 4. / 32.
     401            ey[x + 2] += error * 8. / 32.
     402            ey[x + 3] += error * 4. / 32.
     403            ey[x + 4] += error * 2. / 32.
     404        ep = ey
     405    dest.writePng(name)
     406
     407test324(lenna256bw, "out3-2-4.png")
     408test324(gradient256bw, "grad3-2-4.png")
    381409
    382410##############################################################################
Note: See TracChangeset for help on using the changeset viewer.