Changeset 2186


Ignore:
Timestamp:
01/03/08 01:47:44 (5 years ago)
Author:
sam
Message:
  • Add a colour gradient to the colour tests. They give very insightful information on the various distance choosers.
Location:
www/study
Files:
7 added
3 edited

Legend:

Unmodified
Added
Removed
  • www/study/index.html

    r2181 r2186  
    4646<p> Meet Lenna. She will guide us through this document, because the 
    4747seriousness of a scientific document in the area of computer graphics can 
    48 be measured by the number of times Lenna appears in it. </p> 
     48be measured by the number of times Lenna appears in it. She truly is the 
     49<i>Mona Lisa</i> of image processing. </p> 
    4950 
    5051<p style="text-align: center;"> 
    5152  <img src="lenna256.png" width="256" height="256" 
    5253       class="inline" alt="Lenna (256×256)" /> 
     54  <img src="gradient256.png" width="64" height="256" 
     55       class="inline" alt="colour gradient (64×256)" /> 
    5356  <img src="lenna256bw.png" width="256" height="256" 
    5457       class="inline" alt="Lenna (256×256BW)" /> 
    5558  <img src="gradient256bw.png" width="32" height="256" 
    56        class="inline" alt="gradient" /> 
     59       class="inline" alt="greyscale gradient (32×256)" /> 
    5760</p> 
    5861 
     
    7679 
    7780<ul> 
    78   <li> <a href="part1.html">1. Colour quantisation</a> </li> 
    79   <li> <a href="part2.html">2. Halftoning patterns</a> </li> 
    80   <li> <a href="part3.html">3. Error diffusion</a> </li> 
    81   <li> <a href="part4.html">4. Greyscale dithering</a> </li> 
    82   <li> <a href="part5.html">5. Colour dithering</a> </li> 
    83   <li> <a href="part6.html">6. Photographic mosaics</a> </li> 
     81  <li> <a href="part1.html">1. Colour quantisation</a> 
     82    <ul> 
     83      <li> 1.1. Black and white thresholding </li> 
     84      <li> 1.2. Greyscale thresholding </li> 
     85      <li> 1.3. Dynamic thresholding </li> 
     86      <li> 1.4. Random dithering </li> 
     87    </ul> 
     88  </li> 
     89  <li> <a href="part2.html">2. Halftoning</a> 
     90    <ul> 
     91      <li> 2.1. Halftoning patterns </li> 
     92      <li> 2.2. Screen artifacts </li> 
     93      <li> 2.3. Ordered dithering </li> 
     94      <li> 2.4. Random ordered dithering </li> 
     95      <li> 2.5. Non-rectangular dither tiles </li> 
     96      <li> 2.6. Supercell dithering </li> 
     97      <li> 2.7. Void and cluster method </li> 
     98    </ul> 
     99  </li> 
     100  <li> <a href="part3.html">3. Error diffusion</a> 
     101    <ul> 
     102      <li> 3.1. Floyd-Steinberg error diffusion </li> 
     103      <li> 3.2. Floyd-Steinberg derivatives </li> 
     104      <li> 3.3. Changing image parsing direction </li> 
     105      <li> 3.4. Variable coefficients error diffusion </li> 
     106      <li> 3.5. Block error diffusion </li> 
     107      <li> 3.6. Sub-block error diffusion </li> 
     108    </ul> 
     109  </li> 
     110  <li> <a href="part4.html">4. Greyscale dithering</a> 
     111    <ul> 
     112      <li> 4.1. Introducing gamma </li> 
     113      <li> 4.2. Gamma correction </li> 
     114    </ul> 
     115  </li> 
     116  <li> <a href="part5.html">5. Colour dithering</a> 
     117    <ul> 
     118      <li> 5.1. Separate-space dithering </li> 
     119      <li> 5.2. Accounting for other dimensions </li> 
     120      <li> 5.3. TODO </li> 
     121    </ul> 
     122  </li> 
     123  <li> <a href="part6.html">6. Photographic mosaics</a> 
     124    <ul> 
     125      <li> 6.1. Image classification </li> 
     126    </ul> 
     127  </li> 
    84128</ul> 
    85129 
  • www/study/part5.html

    r2185 r2186  
    8888  <img src="out5-1-1.png" width="256" height="256" 
    8989       class="inline" alt="serpentine FS, 8 colours" /> 
     90  <img src="grad5-1-1.png" width="64" height="256" 
     91       class="inline" alt="serpentine FS, 8 colours gradient" /> 
    9092  <img src="out5-1-2.png" width="256" height="256" 
    9193       class="inline" alt="serpentine FS, 8 colours, gamma-corrected" /> 
     94  <img src="grad5-1-2.png" width="64" height="256" 
     95       class="inline" alt="serpentine FS, 8 colours, gamma-corrected gradient" /> 
    9296</p> 
    9397 
     
    144148  <img src="out5-2-1.png" width="256" height="256" 
    145149       class="inline" alt="Floyd-Steinberg, sum of absolute differences" /> 
     150  <img src="grad5-2-1.png" width="64" height="256" 
     151       class="inline" alt="Floyd-Steinberg, sum of absolute differences gradient" /> 
    146152  <img src="out5-2-2.png" width="256" height="256" 
    147153       class="inline" alt="Floyd-Steinberg, euclidian distance" /> 
     154  <img src="grad5-2-2.png" width="64" height="256" 
     155       class="inline" alt="Floyd-Steinberg, euclidian distance gradient" /> 
    148156</p> 
    149157 
     
    158166  <img src="out5-2-3.png" width="256" height="256" 
    159167       class="inline" alt="Floyd-Steinberg, 1×1 HSV cone" /> 
     168  <img src="grad5-2-3.png" width="64" height="256" 
     169       class="inline" alt="Floyd-Steinberg, 1×1 HSV cone gradient" /> 
    160170  <img src="out5-2-4.png" width="256" height="256" 
    161171       class="inline" alt="Floyd-Steinberg, 3×1 HSV cone" /> 
     172  <img src="grad5-2-4.png" width="64" height="256" 
     173       class="inline" alt="Floyd-Steinberg, 3×1 HSV cone gradient" /> 
    162174</p> 
    163175 
  • www/study/study.py

    r2185 r2186  
    241241if chapter(0): 
    242242    grad256bw = Image((32, 256)) 
    243     for x in range(32): 
    244         for y in range(256): 
     243    for y in range(256): 
     244        for x in range(32): 
    245245            grad256bw.setGray(x, 255 - y, y / 255.) 
    246246    grad256bw.save("gradient256bw.png") 
    247247else: 
    248248    grad256bw = Image("gradient256bw.png") 
     249 
     250# Create a 64x256 colour gradient 
     251if chapter(0): 
     252    grad256 = Image((64, 256), True) 
     253    for y in range(255, -1, -1): 
     254        for x in range(64): 
     255            grad256.setRgb(x, y, x / 63., (255. - y) / 255, x / 63.) 
     256    grad256.save("gradient256.png") 
     257else: 
     258    grad256 = Image("gradient256.png") 
    249259 
    250260############################################################################## 
     
    12531263            for (i, j, e) in err: 
    12541264                img[y + j][x + i] += error * e / total 
    1255     # 4. copy image, replacing gray with white 
     1265    # 4. copy image, replacing grey with white 
    12561266    for y in range(h): 
    12571267        for x in range(w): 
     
    19111921 
    19121922if chapter(5): 
     1923    test51x(grad256, ERROR_FSTEIN, test51y).save("grad5-1-1.png") 
    19131924    test51x(lenna256, ERROR_FSTEIN, test51y).save("out5-1-1.png") 
    1914     out512 = test51x(lenna256, ERROR_FSTEIN, test42x) 
    1915     out512.save("out5-1-2.png") 
     1925    test51x(grad256, ERROR_FSTEIN, test42x).save("grad5-1-2.png") 
     1926    test51x(lenna256, ERROR_FSTEIN, test42x).save("out5-1-2.png") 
    19161927 
    19171928# Pattern 5.2.1: different colours give the same result 
     
    20752086 
    20762087if chapter(5): 
     2088    test52x(grad256, ERROR_FSTEIN, 
     2089            ANSI_PALETTE, distmax, True).save("grad5-2-1.png") 
    20772090    test52x(lenna256, ERROR_FSTEIN, 
    20782091            ANSI_PALETTE, distmax, True).save("out5-2-1.png") 
     2092    test52x(grad256, ERROR_FSTEIN, 
     2093            ANSI_PALETTE, disteuclidian, True).save("grad5-2-2.png") 
    20792094    test52x(lenna256, ERROR_FSTEIN, 
    20802095            ANSI_PALETTE, disteuclidian, True).save("out5-2-2.png") 
     
    20832098    m = (float)(min(r, g, b)) 
    20842099    v = (float)(max(r, g, b)) 
    2085     if v == m: 
     2100    if v == m or v == 0: 
    20862101        return 0., 0., v 
    20872102    s = (v - m) / v 
     
    21132128 
    21142129if chapter(5): 
     2130    test52x(grad256, ERROR_FSTEIN, 
     2131            ANSI_PALETTE, disthsv, True).save("grad5-2-3.png") 
    21152132    test52x(lenna256, ERROR_FSTEIN, 
    21162133            ANSI_PALETTE, disthsv, True).save("out5-2-3.png") 
     2134    test52x(grad256, ERROR_FSTEIN, 
     2135            ANSI_PALETTE, disthsv3, True).save("grad5-2-4.png") 
    21172136    test52x(lenna256, ERROR_FSTEIN, 
    21182137            ANSI_PALETTE, disthsv3, True).save("out5-2-4.png") 
Note: See TracChangeset for help on using the changeset viewer.