Changeset 1899
- Timestamp:
- 11/06/07 09:33:55 (6 years ago)
- Location:
- www/study
- Files:
-
- 1 added
- 2 edited
-
index.html (modified) (3 diffs)
-
pat005.png (added)
-
study.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
www/study/index.html
r1898 r1899 43 43 44 44 <p> This document makes a lot of assumptions, such as the fact that input 45 images are made of pixels that have either one ( luminance) or three (red,45 images are made of pixels that have either one (gray level) or three (red, 46 46 green and blue) values uniformly spread between 0 and 1 (with regards to 47 47 human contrast perception). Real life is more complicated than that, but … … 142 142 </p> 143 143 144 <h3> 2.2. Gamma considerations </h3> 145 146 <p> If your display is not very good, you might see slightly different 147 shades of gray for the following patterns, despite being made of 50% 144 <p> Not bad for a start. But there is a lot to improve. </p> 145 146 <h3> 2.2. Screen artifacts </h3> 147 148 <p> If your screen’s quality is not very good, you might experience slightly 149 different shades of gray for the following patterns, despite being made of 50% 148 150 black and 50% white pixels: </p> 149 151 150 152 <p style="text-align: center;"> 151 153 <img src="pat003.png" width="240" height="80" 152 class="inline" alt="introducing gamma" /> 153 </p> 154 155 <p> But more importantly, if you are reading this document on a computer 154 class="inline" alt="screen imperfections" /> 155 </p> 156 157 <h3> 2.3. Gamma considerations </h3> 158 159 <p> More importantly, if you are reading this document on a computer 156 160 screen, you may have noticed that the above 50% pattern was closer to a 0.73 157 grayscale (left) than to the expected 0.5 value (right). If you are reading158 a printed copy, it might be a different matter. </p>161 grayscale (left) than to the intuitively expected 0.5 value (right). If you 162 are reading a printed copy, it might be a different matter. </p> 159 163 160 164 <p style="text-align: center;"> … … 167 171 white pattern is equivalent to a gray value of 0.73 instead of 0.5. Conversely, 168 172 it clearly means that a gray value of 0.5 should not be approached with a 50% 169 black and white dither patterns. </p>173 dither pattern. </p> 170 174 171 175 <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 gray values of 0.53, 0.73 and 0.88), one should rather use 6.25%, 25% and 50% 177 patterns, which give the better spread gray values of 0.28, 0.53 and 0.73 178 and result far more accurate gradients. This is especially obvious when 179 observing the high intensity drop between the 25% pattern and black (top row): 180 </p> 181 182 <p style="text-align: center;"> 183 <img src="pat005.png" width="400" height="240" 184 class="inline" alt="better gradients" /> 185 </p> 186 187 <p> Here is the result on Lenna. As you can see, the result is visually less 188 appealing than with the “incorrect” colours. But when seen from a distance, 189 there is no doubt this version is more accurate: </p> 176 190 177 191 <p style="text-align: center;"> -
www/study/study.py
r1898 r1899 147 147 dest.writePng("pat004.png") 148 148 149 # Pattern 5: gamma-corrected 50% gray, black-white halftone, 50% gray 150 dest = Image((400, 240)) 151 for y in range(80): 152 for x in range(400): 153 if x < 80: 154 c = 0. 155 elif x < 160: 156 c = ((x + y) & 1) and (y & 1) 157 elif x < 240: 158 c = (x + y) & 1 159 elif x < 320: 160 c = ((x + y) & 1) or (y & 1) 161 else: 162 c = 1. 163 dest.setGray(x, y, c) 164 for y in range(80, 160): 165 for x in range(400): 166 dest.setGray(x, y, x / 80 / 4.) 167 for y in range(160, 240): 168 for x in range(400): 169 if x < 80: 170 c = 0. 171 elif x < 160: 172 c = (((x + y) & 3) == 1) and ((y & 3) == 1) 173 elif x < 240: 174 c = ((x + y) & 1) and (y & 1) 175 elif x < 320: 176 c = (x + y) & 1 177 else: 178 c = 1. 179 dest.setGray(x, y, c) 180 dest.writePng("pat005.png") 181 149 182 # Output 6: gamma-aware 20/40/60/80% threshold: 150 183 dest = Image((w, h))
Note: See TracChangeset
for help on using the changeset viewer.
