Changeset 2010Tweet

Ignore:
Timestamp:
Nov 17, 2007, 4:02:51 PM (13 years ago)
Message:
• Preparing random matrix halftoning.
Location:
www/study
Files:
2 edited

Unmodified
Added
Removed
• www/study/part2.html

 r2006

• www/study/study.py

 r2007 test241(gradient256bw).save("grad2-4-1.png") # Output 2.4.2: random dithering # Output 2.4.2: gaussian random dithering def test242(src): random.seed(0) test242(lenna256bw).save("out2-4-2.png") test242(gradient256bw).save("grad2-4-2.png") # Output 2.4.3: random dither matrices def test243(src, mat): random.seed(0) (w, h) = src.size() dest = Image((w, h)) dx = len(mat[0]) dy = len(mat) randmat = [[(int)(random.random() * 16) for x in range(w / dx)] for y in range(h / dy)] for y in range(h): for x in range(w): c = src.getGray(x, y) val = (mat[y % dy][x % dx] + randmat[y / dy][x / dx]) % (dx * dy) threshold = (1. + val) / (dx * dy + 1) c = c > threshold dest.setGray(x, y, c) return dest test243(lenna256bw, DITHER_BAYER44).save("out2-4-3.png") test243(gradient256bw, DITHER_BAYER44).save("grad2-4-3.png") ##############################################################################
Note: See TracChangeset for help on using the changeset viewer.