Changes between Version 1 and Version 2 of libcaca/study/5


Ignore:
Timestamp:
12/22/2009 09:21:17 PM (14 years ago)
Author:
Sam Hocevar
Comment:

fix image links

Legend:

Unmodified
Added
Removed
Modified
  • libcaca/study/5

    v1 v2  
    33At first sight, generalising dithering to three grey scales seems pretty straightforward: just add grey 0.5 in the middle of the palette and dither pixels in the [0, 0.5] range with black and grey, and pixels in the [0.5, 1] range with grey and white. Here are two different results with 8×8 Bayer ordered dithering and with serpentine Floyd-Steinberg error diffusion:
    44
    5 [[Image(source:/web/trunk/static/study/out/lena5-0-1.png,class="inline",alt="8×8 Bayer ordered dithering, 3 colours")]]
    6 [[Image(source:/web/trunk/static/study/out/grad5-0-1.png,class="inline",alt="8×8 Bayer ordered dithering gradient, 3 colours")]]
    7 [[Image(source:/web/trunk/static/study/out/lena5-0-2.png,class="inline",alt="serpentine FS error diffusion, 3 colours")]]
    8 [[Image(source:/web/trunk/static/study/out/grad5-0-2.png,class="inline",alt="serpentine FS error diffusion gradient, 3 colours")]]
     5[[Image(source:/web/trunk/www/study/out/lena5-0-1.png,class="inline",alt="8×8 Bayer ordered dithering, 3 colours")]]
     6[[Image(source:/web/trunk/www/study/out/grad5-0-1.png,class="inline",alt="8×8 Bayer ordered dithering gradient, 3 colours")]]
     7[[Image(source:/web/trunk/www/study/out/lena5-0-2.png,class="inline",alt="serpentine FS error diffusion, 3 colours")]]
     8[[Image(source:/web/trunk/www/study/out/grad5-0-2.png,class="inline",alt="serpentine FS error diffusion gradient, 3 colours")]]
    99
    1010These are pretty much the images that imaging software such as The Gimp would give (using “positioned” and “Floyd-Steinberg” dithering modes).
     
    1818If you are reading this document on a computer screen, you may have noticed that the black and white 50% pattern was closer to a 0.73 greyscale (left) than to the intuitively expected 0.5 value (right). If you are reading a printed copy, it might be a different matter.
    1919
    20 [[Image(source:/web/trunk/static/study/out/pat5-1-1.png,class="inline",alt="introducing gamma")]]
     20[[Image(source:/web/trunk/www/study/out/pat5-1-1.png,class="inline",alt="introducing gamma")]]
    2121
    2222The mapping linking greyscale steps to intensities is called '''gamma correction'''. An approximate law for gamma correction is given as ''I = v^γ^'', where ''v'' is the coded colour value (between 0 and 1), ''I'' is the perceived colour intensity (between 0% and 100%) and ''γ'' is the gamma. A pattern made of even-numbered 0%-intensity pixels and 100%-intensity pixels has an intensity of 50% by definition. But the corresponding greyscale depends on the gamma value.
     
    2424Most modern computer systems use the sRGB gamma model close to the law with ''γ = 2.2''. As can be seen, it is highly non-linear:
    2525
    26 [[Image(source:/web/trunk/static/study/fig5-1-1.png,alt="introducing gamma")]]
     26[[Image(source:/web/trunk/www/study/fig5-1-1.png,alt="introducing gamma")]]
    2727
    2828Éric Brasseur wrote [http://www.4p8.com/eric.brasseur/gamma.html a pretty comprehensive essay] ![16] about why on a computer screen a 50% black and white pattern should be scaled down to a grey value of 0.73 instead of 0.5 and how major computer graphics software totally misses the point. Conversely, it clearly means that a grey value of 0.5 should not be emulated with a 50% dither pattern.
     
    3030The following figure shows the gamma curve for the naïve three-colour greyscale gradient we saw above (red curve) compared to the two-colour gradient (blue curve). Two major observations can be made: the new curve is far closer to a perfect, linear gradient, but there is a singularity in the middle of the curve, meaning a break in the gradient’s smoothness.
    3131
    32 [[Image(source:/web/trunk/static/study/fig5-1-2.png,alt="3-colour gamma")]]
     32[[Image(source:/web/trunk/www/study/fig5-1-2.png,alt="3-colour gamma")]]
    3333
    3434There are three possible ways to reduce the singularity and make the gradient smoother and/or closer to the original colours:
     
    4242Gamma correction consists in converting pixel values into intensity values before performing operations on them, then reconverting them to pixel values before displaying them. The exact same algorithms can be used, they just operate on slightly different data.
    4343
    44 [[Image(source:/web/trunk/static/study/fig5-1-3.png,alt="3-colour gamma coorection")]]
     44[[Image(source:/web/trunk/www/study/fig5-1-3.png,alt="3-colour gamma coorection")]]
    4545
    4646Here are the results of gamma-correcting input pixels before doing any computation on them, then using serpentine Floyd-Steinberg error diffusion:
    4747
    48 [[Image(source:/web/trunk/static/study/out/lena5-2-1.png,class="inline",alt="serpentine FS, 2 colours, gamma-corrected")]]
    49 [[Image(source:/web/trunk/static/study/out/grad5-2-1.png,class="inline",alt="serpentine FS, 2 colours, gamma-corrected gradient")]]
    50 [[Image(source:/web/trunk/static/study/out/lena5-2-2.png,class="inline",alt="serpentine FS, 3 colours, gamma-corrected")]]
    51 [[Image(source:/web/trunk/static/study/out/grad5-2-2.png,class="inline",alt="serpentine FS, 3 colours, gamma-corrected gradient")]]
     48[[Image(source:/web/trunk/www/study/out/lena5-2-1.png,class="inline",alt="serpentine FS, 2 colours, gamma-corrected")]]
     49[[Image(source:/web/trunk/www/study/out/grad5-2-1.png,class="inline",alt="serpentine FS, 2 colours, gamma-corrected gradient")]]
     50[[Image(source:/web/trunk/www/study/out/lena5-2-2.png,class="inline",alt="serpentine FS, 3 colours, gamma-corrected")]]
     51[[Image(source:/web/trunk/www/study/out/grad5-2-2.png,class="inline",alt="serpentine FS, 3 colours, gamma-corrected gradient")]]
    5252
    5353Two-colour dithering is not visually satisfying: dark areas lack much detail because the gamma curve is very flat at low intensities. However, the result itself is far more accurate that previously. The problem, while still visible, is even less important with three-colour dithering: the image on the right is superior to what The Gimp or Adobe Photoshop are able to come up with.
     
    5555Finally, this is gamma-corrected 4-colour dithering:
    5656
    57 [[Image(source:/web/trunk/static/study/out/lena5-2-3.png,class="inline",alt="serpentine FS, 4 colours, gamma-corrected")]]
    58 [[Image(source:/web/trunk/static/study/out/grad5-2-3.png,class="inline",alt="serpentine FS, 4 colours, gamma-corrected gradient")]]
     57[[Image(source:/web/trunk/www/study/out/lena5-2-3.png,class="inline",alt="serpentine FS, 4 colours, gamma-corrected")]]
     58[[Image(source:/web/trunk/www/study/out/grad5-2-3.png,class="inline",alt="serpentine FS, 4 colours, gamma-corrected gradient")]]
    5959
    6060== 5.3. Greyscale sub-block error diffusion ==
     
    6464The following picture uses all possible 4-greyscale 2×2 tiles. The output quality is very close to what standard, pixel-per-pixel error diffusion achieves:
    6565
    66 [[Image(source:/web/trunk/static/study/out/lena5-3-1.png,class="inline",alt="sub-block FS, full 4-grey tiles")]]
    67 [[Image(source:/web/trunk/static/study/out/grad5-3-1.png,class="inline",alt="sub-block FS, full 4-grey tiles gradient")]]
     66[[Image(source:/web/trunk/www/study/out/lena5-3-1.png,class="inline",alt="sub-block FS, full 4-grey tiles")]]
     67[[Image(source:/web/trunk/www/study/out/grad5-3-1.png,class="inline",alt="sub-block FS, full 4-grey tiles gradient")]]
    6868
    6969And finally, this picture only uses 4-greyscale combinations of the “lines” tiles seen previously:
    7070
    71 [[Image(source:/web/trunk/static/study/fig5-3-1.png,class="matrix",alt="list of 4-grey 2×2 pixel blocks")]]
    72 [[Image(source:/web/trunk/static/study/out/lena5-3-2.png,class="inline",alt="sub-block FS, lines 4-grey tiles")]]
    73 [[Image(source:/web/trunk/static/study/out/grad5-3-2.png,class="inline",alt="sub-block FS, lines 4-grey tiles gradient")]]
     71[[Image(source:/web/trunk/www/study/fig5-3-1.png,class="matrix",alt="list of 4-grey 2×2 pixel blocks")]]
     72[[Image(source:/web/trunk/www/study/out/lena5-3-2.png,class="inline",alt="sub-block FS, lines 4-grey tiles")]]
     73[[Image(source:/web/trunk/www/study/out/grad5-3-2.png,class="inline",alt="sub-block FS, lines 4-grey tiles gradient")]]