Changes between Version 3 and Version 4 of libcaca/study/1


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

fix image links

Legend:

Unmodified
Added
Removed
Modified
  • libcaca/study/1

    v3 v4  
    1212Since a greyscale pixel has a value between 0 and 1, a fast method to convert the image to black and white is to set all pixels below 0.5 to black and all pixels above 0.5 to white. This method is called thresholding and, in our case, results in the following image:
    1313
    14 [[Image(source:/web/trunk/static/study/out/lena1-1-1.png,alt="50% threshold")]]
    15 [[Image(source:/web/trunk/static/study/out/grad1-1-1.png,alt="50% threshold gradient")]]
     14[[Image(source:/web/trunk/www/study/out/lena1-1-1.png,alt="50% threshold")]]
     15[[Image(source:/web/trunk/www/study/out/grad1-1-1.png,alt="50% threshold gradient")]]
    1616
    1717Not that bad, but we were pretty lucky: the original image’s brightness was rather well balanced. A lot of detail is lost, though. Different results can be obtained by choosing “threshold values” other than 0.5, for instance 0.4 or 0.6, resulting in a much brighter or darker image:
    1818
    19 [[Image(source:/web/trunk/static/study/out/lena1-1-2.png,alt="40% threshold")]]
    20 [[Image(source:/web/trunk/static/study/out/grad1-1-2.png,alt="40% threshold gradient")]]
    21 [[Image(source:/web/trunk/static/study/out/lena1-1-3.png,alt="60% threshold")]]
    22 [[Image(source:/web/trunk/static/study/out/grad1-1-3.png,alt="60% threshold gradient")]]
     19[[Image(source:/web/trunk/www/study/out/lena1-1-2.png,alt="40% threshold")]]
     20[[Image(source:/web/trunk/www/study/out/grad1-1-2.png,alt="40% threshold gradient")]]
     21[[Image(source:/web/trunk/www/study/out/lena1-1-3.png,alt="60% threshold")]]
     22[[Image(source:/web/trunk/www/study/out/grad1-1-3.png,alt="60% threshold gradient")]]
    2323
    2424Choosing the best thresholding value for a given image is called average dithering. But even with the best value, the results will not improve tremendously.
     
    2828Better results can be achieved with a slightly bigger palette. Here is thresholding applied to a 3-colour and to a 5-colour palette:
    2929
    30 [[Image(source:/web/trunk/static/study/out/lena1-2-1.png,alt="3-colour threshold")]]
    31 [[Image(source:/web/trunk/static/study/out/grad1-2-1.png,alt="3-colour threshold gradient")]]
    32 [[Image(source:/web/trunk/static/study/out/lena1-2-2.png,alt="5-colour threshold")]]
    33 [[Image(source:/web/trunk/static/study/out/grad1-2-2.png,alt="5-colour threshold gradient")]]
     30[[Image(source:/web/trunk/www/study/out/lena1-2-1.png,alt="3-colour threshold")]]
     31[[Image(source:/web/trunk/www/study/out/grad1-2-1.png,alt="3-colour threshold gradient")]]
     32[[Image(source:/web/trunk/www/study/out/lena1-2-2.png,alt="5-colour threshold")]]
     33[[Image(source:/web/trunk/www/study/out/grad1-2-2.png,alt="5-colour threshold gradient")]]
    3434
    3535Using this method, shades of grey are evenly used. However, the global error is far from optimal, as the following graphs show:
    3636
    37 [[Image(source:/web/trunk/static/study/fig1-2-1.png,alt="mean error 0.138")]]
    38 [[Image(source:/web/trunk/static/study/fig1-2-2.png,alt="mean error 0.075")]]
     37[[Image(source:/web/trunk/www/study/fig1-2-1.png,alt="mean error 0.138")]]
     38[[Image(source:/web/trunk/www/study/fig1-2-2.png,alt="mean error 0.075")]]
    3939
    4040The following thresholding method minimises the error, at the cost of underusage of pure black and white colours:
    4141
    42 [[Image(source:/web/trunk/static/study/out/lena1-2-3.png,alt="3-colour threshold, minimal error")]]
    43 [[Image(source:/web/trunk/static/study/out/grad1-2-3.png,alt="3-colour threshold gradient, minimal error")]]
    44 [[Image(source:/web/trunk/static/study/out/lena1-2-4.png,alt="5-colour threshold, minimal error")]]
    45 [[Image(source:/web/trunk/static/study/out/grad1-2-4.png,alt="5-colour threshold gradient, minimal error")]]
     42[[Image(source:/web/trunk/www/study/out/lena1-2-3.png,alt="3-colour threshold, minimal error")]]
     43[[Image(source:/web/trunk/www/study/out/grad1-2-3.png,alt="3-colour threshold gradient, minimal error")]]
     44[[Image(source:/web/trunk/www/study/out/lena1-2-4.png,alt="5-colour threshold, minimal error")]]
     45[[Image(source:/web/trunk/www/study/out/grad1-2-4.png,alt="5-colour threshold gradient, minimal error")]]
    4646
    47 [[Image(source:/web/trunk/static/study/fig1-2-3.png,alt="mean error 0.125")]]
    48 [[Image(source:/web/trunk/static/study/fig1-2-4.png,alt="mean error 0.0625")]]
     47[[Image(source:/web/trunk/www/study/fig1-2-3.png,alt="mean error 0.125")]]
     48[[Image(source:/web/trunk/www/study/fig1-2-4.png,alt="mean error 0.0625")]]
    4949
    5050This is a perfect example of a situation where colour accuracy does not help achieve a better result.
     
    5454Dynamic thresholding consists in studying the image before selecting the threshold values. One strategy, for instance, is to choose the median pixel value. This is done simply by computing a histogram of the image.
    5555
    56 [[Image(source:/web/trunk/static/study/out/lena1-3-1.png,alt="2-colour dynamic threshold")]]
    57 [[Image(source:/web/trunk/static/study/out/grad1-3-1.png,alt="2-colour dynamic threshold gradient")]]
    58 [[Image(source:/web/trunk/static/study/out/lena1-3-2.png,alt="5-colour dynamic threshold")]]
    59 [[Image(source:/web/trunk/static/study/out/grad1-3-2.png,alt="5-colour dynamic threshold gradient")]]
     56[[Image(source:/web/trunk/www/study/out/lena1-3-1.png,alt="2-colour dynamic threshold")]]
     57[[Image(source:/web/trunk/www/study/out/grad1-3-1.png,alt="2-colour dynamic threshold gradient")]]
     58[[Image(source:/web/trunk/www/study/out/lena1-3-2.png,alt="5-colour dynamic threshold")]]
     59[[Image(source:/web/trunk/www/study/out/grad1-3-2.png,alt="5-colour dynamic threshold gradient")]]
    6060
    6161== 1.4. Random dithering ==
     
    6565Here are two simple examples. On the left, threshold values are uniformly chosen between 0 and 1. On the right, random dithering with threshold values chosen with a gaussian distribution (mean 0.5, standard deviation 0.15):
    6666
    67 [[Image(source:/web/trunk/static/study/out/lena1-4-1.png,alt="random dithering")]]
    68 [[Image(source:/web/trunk/static/study/out/grad1-4-1.png,alt="random dithering gradient")]]
    69 [[Image(source:/web/trunk/static/study/out/lena1-4-2.png,alt="gaussian (0.5, 0.15) random dithering")]]
    70 [[Image(source:/web/trunk/static/study/out/grad1-4-2.png,alt="gaussian (0.5, 0.15) random dithering gradient")]]
     67[[Image(source:/web/trunk/www/study/out/lena1-4-1.png,alt="random dithering")]]
     68[[Image(source:/web/trunk/www/study/out/grad1-4-1.png,alt="random dithering gradient")]]
     69[[Image(source:/web/trunk/www/study/out/lena1-4-2.png,alt="gaussian (0.5, 0.15) random dithering")]]
     70[[Image(source:/web/trunk/www/study/out/grad1-4-2.png,alt="gaussian (0.5, 0.15) random dithering gradient")]]
    7171
    7272The images look very noisy, but they are arguably an improvement over standard constant thresholding.
     
    7474Finally, this is dynamic thresholding with 4 colours where threshold values at every pixel are computed as usual, but then perturbated using a gaussian distribution (mean 0, standard deviation 0.08):
    7575
    76 [[Image(source:/web/trunk/static/study/out/lena1-4-3.png,alt="4-colour dynamic thresholding, gaussian (0, 0.08)")]]
    77 [[Image(source:/web/trunk/static/study/out/grad1-4-3.png,alt="4-colour dynamic thresholding, gaussian (0, 0.08) gradient")]]
     76[[Image(source:/web/trunk/www/study/out/lena1-4-3.png,alt="4-colour dynamic thresholding, gaussian (0, 0.08)")]]
     77[[Image(source:/web/trunk/www/study/out/grad1-4-3.png,alt="4-colour dynamic thresholding, gaussian (0, 0.08) gradient")]]