- Timestamp:
- Nov 6, 2007, 2:33:27 AM (15 years ago)
- Location:
- www/study
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
www/study/index.html
r1897 r1898 169 169 black and white dither patterns. </p> 170 170 171 <p> So, instead of using 25%, 50% and 75% patterns (which give non-uniform 172 gray values of 0.53, 0.73 and 0.88), let’s try with 6.25%, 25% and 50% 173 patterns (which give the better spread gray values of 0.28, 0.53 and 0.73). 174 As you can see, the result is visually less appealing. But the important 175 part here is that color accuracy is higher: </p> 176 177 <p style="text-align: center;"> 178 <img src="out007.png" width="256" height="256" 179 class="inline" alt="gamma-aware 6.25%, 25% and 50% halftoning" /> 180 </p> 181 171 182 <!-- 172 183 <p> Here is the application to Lenna, using the 0-0.2, 0.2-0.4, 0.4-0.6, -
www/study/study.py
r1897 r1898 37 37 (w, h) = src.size() 38 38 39 # Test 1: 50% threshold39 # Output 1: 50% threshold 40 40 dest = Image((w, h)) 41 41 for y in range(h): … … 46 46 del dest 47 47 48 # Test 2: 40% threshold48 # Output 2: 40% threshold 49 49 dest = Image((w, h)) 50 50 for y in range(h): … … 55 55 del dest 56 56 57 # Test 3: 60% threshold57 # Output 3: 60% threshold 58 58 dest = Image((w, h)) 59 59 for y in range(h): … … 64 64 del dest 65 65 66 # Test 4: 3-colour threshold66 # Output 4: 3-colour threshold 67 67 dest = Image((w, h)) 68 68 for y in range(h): … … 73 73 dest.writePng("out004.png") 74 74 75 # Test 5: 4-colour threshold75 # Output 5: 4-colour threshold 76 76 dest = Image((w, h)) 77 77 for y in range(h): … … 103 103 dest.writePng("pat002.png") 104 104 105 # Test 6: 20/40/60/80% threshold with 25/50/75% halftone patterns inbetween:105 # Output 6: 20/40/60/80% threshold with 25/50/75% halftone patterns inbetween: 106 106 dest = Image((w, h)) 107 107 for y in range(h): … … 147 147 dest.writePng("pat004.png") 148 148 149 # Output 6: gamma-aware 20/40/60/80% threshold: 150 dest = Image((w, h)) 151 for y in range(h): 152 for x in range(w): 153 c = src.getGray(x, y) 154 if c < 0.2: 155 c = 0. 156 elif c < 0.4: 157 c = (((x + y) & 3) == 1) and ((y & 3) == 1) 158 elif c < 0.6: 159 c = ((x + y) & 1) and (y & 1) 160 elif c < 0.8: 161 c = (x + y) & 1 162 else: 163 c = 1. 164 dest.setGray(x, y, c) 165 dest.writePng("out007.png") 166 149 167 ############################################################################## 150 168 # Only temporary cruft below this … … 152 170 import sys 153 171 sys.exit(0) 154 155 # Test 4: 33/66% threshold with 50% halftone pattern inbetween:156 dest = Image((w, h))157 for y in range(h):158 for x in range(w):159 c = src.getGray(x, y)160 if c < 0.333:161 c = 0.162 elif c < 0.666:163 c = (x + y) & 1164 else:165 c = 1.166 dest.setGray(x, y, c)167 dest.writePng("test4.png")168 172 169 173 # Create a dot-matrix pattern
Note: See TracChangeset
for help on using the changeset viewer.