Changeset 1968


Ignore:
Timestamp:
Nov 16, 2007, 2:34:16 AM (13 years ago)
Author:
Sam Hocevar
Message:
  • Simple error diffusion.
Location:
www/study
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • www/study/part3.html

    r1956 r1968  
    3939</p>
    4040
    41 <h3> 3.1. Floyd-Steinberg error diffusion </h3>
    42 
    43 <p> The most famous error diffusion method is the <b>Floyd-Steinberg</b>
    44 algorithm.  It handles each pixel of the image one after the other and
    45 propagates the error to adjacent pixels: </p>
    46 
    47 <p style="text-align: center;">
    48   <img src="fig3-1-1.png" width="120" height="120" alt="Floyd-Steinberg" />
    49 </p>
    50 
    5141<p> The error is computed by simply substracting the source value and the
    5242destination value. Destination value can be chosen by many means but does
    53 not impact the image a lot compared to the error distribution coefficients
    54 choice. The image on the left is the result using a 0.5 threshold. The image
    55 on the right is a variant called <b>serpentine Floyd-Steinberg</b> that parses
    56 every odd line in reverse order (right to left). The results are very close
    57 to the original Floyd-Steinberg, but the method avoids artifacts in some
    58 corner cases: </p>
     43not impact the image a lot with most methods in comparison to the crucial
     44choice of error distribution coefficients. </p>
     45
     46<p> This is the simplest error diffusion method. It thresholds the image
     47to 0.5 and propagates 100% of the error the the next (right) pixel: </p>
     48
     49<p style="text-align: center;">
     50  <img src="out3-0-1.png" width="256" height="256"
     51       class="inline" alt="Simple error diffusion" />
     52  <img src="grad3-0-1.png" width="32" height="256"
     53       class="inline" alt="Simple error diffusion gradient" />
     54</p>
     55
     56<h3> 3.1. Floyd-Steinberg error diffusion </h3>
     57
     58<p> The most famous error diffusion method is the <b>Floyd-Steinberg</b>
     59algorithm. It propagates the error to more than one adjacent pixels using
     60the following coefficients: </p>
     61
     62<p style="text-align: center;">
     63  <img src="fig3-1-1.png" width="120" height="120" alt="Floyd-Steinberg" />
     64</p>
     65
     66On the left is the result of the simple algorithm. The image on the right is
     67a variant called <b>serpentine Floyd-Steinberg</b> which parses every odd line
     68in reverse order (right to left). The results are very close to the original
     69Floyd-Steinberg, but the method avoids artifacts in some corner cases: </p>
    5970
    6071<p style="text-align: center;">
  • www/study/study.py

    r1942 r1968  
    276276        ey[lines - 1] = [0.] * (w + rows - 1)
    277277    dest.writePng(name)
     278
     279mat = [[ -1, 1]]
     280test3xx(lenna256bw, mat, False, "out3-0-1.png")
     281test3xx(gradient256bw, mat, False, "grad3-0-1.png")
    278282
    279283mat = [[    0.,    -1, 7./16],
Note: See TracChangeset for help on using the changeset viewer.