Changeset 1991
- Timestamp:
- Nov 16, 2007, 10:02:59 PM (13 years ago)
- Location:
- www/study
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
www/study/study.py
r1980 r1991 499 499 test42x(gradient256bw, ERROR_FSTEIN, threshold_4).writePng("grad4-2-3.png") 500 500 501 # Pattern 5. 0.1: 8-colour palette501 # Pattern 5.1.1: 8-colour palette 502 502 dest = Image((512, 64)) 503 503 for x in range(512): … … 513 513 lenna256 = Image("lenna256.png") 514 514 515 # Output 5.0.1: RGB dithering 515 # Output 5.1.1: 8-colour Floyd-Steinberg RGB dithering 516 # Output 5.1.2: 8-colour gamma-corrected Floyd-Steinberg RGB dithering 516 517 def test501(src, mat, func): 517 518 (w, h) = src.size() … … 534 535 test501(lenna256, ERROR_FSTEIN, test42x).writePng("out5-1-2.png") 535 536 537 # Pattern 5.1.2: red-green or red-yellow pattern? 538 dest = Image((240, 160)) 539 for x in range(80): 540 for y in range(80): 541 r = DITHER_BAYER44[(y / 4) % 4][(x / 4) % 4] > 11 542 g = DITHER_BAYER44[(y / 4) % 4][(x / 4) % 4] > 13 543 dest.setRgb(x, y, r, 0, g) 544 for y in range(80, 160): 545 r = DITHER_BAYER44[y % 4][x % 4] > 11 546 g = DITHER_BAYER44[y % 4][x % 4] > 13 547 dest.setRgb(x, y, r, 0, g) 548 for x in range(80, 160): 549 for y in range(80): 550 r = DITHER_BAYER44[(y / 4 + 1) % 4][(x / 4 + 1) % 4] > 11 551 g = DITHER_BAYER44[(y / 4) % 4][(x / 4) % 4] > 13 552 dest.setRgb(x, y, r, 0, g) 553 for y in range(80, 160): 554 r = DITHER_BAYER44[(y + 1) % 4][(x + 1) % 4] > 11 555 g = DITHER_BAYER44[y % 4][x % 4] > 13 556 dest.setRgb(x, y, r, 0, g) 557 for x in range(160, 240): 558 for y in range(80): 559 r = DITHER_BAYER44[(y / 4) % 4][(x / 4 + 1) % 4] > 11 560 g = DITHER_BAYER44[(y / 4) % 4][(x / 4) % 4] > 13 561 dest.setRgb(x, y, r, 0, g) 562 for y in range(80, 160): 563 r = DITHER_BAYER44[y % 4][(x + 1) % 4] > 11 564 g = DITHER_BAYER44[y % 4][x % 4] > 13 565 dest.setRgb(x, y, r, 0, g) 566 dest.writePng("pat5-1-2.png") 567 536 568 ############################################################################## 537 569 # Place temporary cruft below this
Note: See TracChangeset
for help on using the changeset viewer.