Changeset 1899


Ignore:
Timestamp:
11/06/07 09:33:55 (6 years ago)
Author:
sam
Message:
  • New gradient pattern to make gamma issues more obvious.
Location:
www/study
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • www/study/index.html

    r1898 r1899  
    4343 
    4444<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, 
     45images are made of pixels that have either one (gray level) or three (red, 
    4646green and blue) values uniformly spread between 0 and 1 (with regards to 
    4747human contrast perception). Real life is more complicated than that, but 
     
    142142</p> 
    143143 
    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 
     149different shades of gray for the following patterns, despite being made of 50% 
    148150black and 50% white pixels: </p> 
    149151 
    150152<p style="text-align: center;"> 
    151153  <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 
    156160screen, 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 reading 
    158 a printed copy, it might be a different matter. </p> 
     161grayscale (left) than to the intuitively expected 0.5 value (right). If you 
     162are reading a printed copy, it might be a different matter. </p> 
    159163 
    160164<p style="text-align: center;"> 
     
    167171white pattern is equivalent to a gray value of 0.73 instead of 0.5. Conversely, 
    168172it clearly means that a gray value of 0.5 should not be approached with a 50% 
    169 black and white dither patterns. </p> 
     173dither pattern. </p> 
    170174 
    171175<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> 
     176gray values of 0.53, 0.73 and 0.88), one should rather use 6.25%, 25% and 50% 
     177patterns, which give the better spread gray values of 0.28, 0.53 and 0.73 
     178and result far more accurate gradients. This is especially obvious when 
     179observing 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 
     188appealing than with the “incorrect” colours. But when seen from a distance, 
     189there is no doubt this version is more accurate: </p> 
    176190 
    177191<p style="text-align: center;"> 
  • www/study/study.py

    r1898 r1899  
    147147dest.writePng("pat004.png") 
    148148 
     149# Pattern 5: gamma-corrected 50% gray, black-white halftone, 50% gray 
     150dest = Image((400, 240)) 
     151for 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) 
     164for y in range(80, 160): 
     165    for x in range(400): 
     166        dest.setGray(x, y, x / 80 / 4.) 
     167for 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) 
     180dest.writePng("pat005.png") 
     181 
    149182# Output 6: gamma-aware 20/40/60/80% threshold: 
    150183dest = Image((w, h)) 
Note: See TracChangeset for help on using the changeset viewer.