|
|
Line 1: |
Line 1: |
| {| style="width:300px; float:right; border:1px solid #ccc; background:#f9f9f9; font-size:88%; line-height:1.5em; margin:5px;"
| | Hi there, I am Andrew Berryhill. The favorite hobby for him and his kids is to perform lacross and he would never give it up. My working day occupation is a travel agent. Some time in the past she chose to live in Alaska and her parents live close by.<br><br>My web-site [http://www.Prayerarmor.com/uncategorized/dont-know-which-kind-of-hobby-to-take-up-read-the-following-tips/ love psychic] |
| | [[File:RGB 24bits palette sample image.jpg]]
| |
| | [[File:RGB 24bits palette sample image - 3-bit RGB.png]]
| |
| |-
| |
| | colspan="2" width="300px" | Example of a 24-bit RGB image dithered to [[List_of_monochrome_and_RGB_palettes#3-bit_RGB|3-bit RGB]] using Floyd–Steinberg dithering
| |
| |}
| |
| | |
| [[Image:Michelangelo's David - Floyd-Steinberg.png|thumb|right|An image of the [[David (Michelangelo)|Statue of David]], dithered with Floyd–Steinberg algorithm]]
| |
| | |
| '''Floyd–Steinberg dithering''' is an image [[dithering]] algorithm first published in 1976 by [[Robert W. Floyd]] and [[Louis Steinberg]]. It is commonly used by image manipulation software, for example when an image is converted into [[GIF]] format that is restricted to a maximum of 256 colors.
| |
| | |
| The algorithm achieves dithering by pushing (adding) the residual [[quantization error]] of a [[pixel]] onto its neighboring pixels, to be dealt with later. It spreads the debt out according to the distribution (shown as a map of the neighboring pixels):
| |
| : <math>
| |
| \begin{bmatrix}
| |
| & & & & \\
| |
| & & * & \frac{\displaystyle 7}{\displaystyle 16} & ... \\
| |
| ... & \frac{\displaystyle 3}{\displaystyle 16} & \frac{\displaystyle 5}{\displaystyle 16} & \frac{\displaystyle 1}{\displaystyle 16} & ... \\
| |
| \end{bmatrix}
| |
| </math>
| |
| The pixel indicated with a star (*) indicates the pixel currently being scanned, and the blank pixels are the previously-scanned pixels.
| |
| The algorithm scans the image from left to right, top to bottom, quantizing pixel values one by one. Each time the quantization error is transferred to the neighboring pixels, while not affecting the pixels that already have been quantized. Hence, if a number of pixels have been rounded downwards, it becomes more likely that the next pixel is rounded upwards, such that on average, the quantization error is close to zero.
| |
| | |
| The diffusion coefficients have the property that if the original pixel values are exactly halfway in between the nearest available colors, the dithered result is a checkerboard pattern. For example 50% grey data could be dithered as a black-and-white checkerboard pattern. For optimal dithering, the counting of quantization errors should be in sufficient accuracy to prevent rounding errors from affecting the result.
| |
| | |
| In some implementations, the horizontal direction of scan alternates between lines; this is called "serpentine scanning" or [[boustrophedon transform]] dithering.
| |
| | |
| In [[pseudocode]]:
| |
| '''for each''' y from top to bottom
| |
| '''for each''' x from left to right
| |
| oldpixel := pixel[x][y]
| |
| newpixel := find_closest_palette_color(oldpixel)
| |
| pixel[x][y] := newpixel
| |
| quant_error := oldpixel - newpixel
| |
| pixel[x+1][y ] := pixel[x+1][y ] + 7/16 * quant_error
| |
| pixel[x-1][y+1] := pixel[x-1][y+1] + 3/16 * quant_error
| |
| pixel[x ][y+1] := pixel[x ][y+1] + 5/16 * quant_error
| |
| pixel[x+1][y+1] := pixel[x+1][y+1] + 1/16 * quant_error
| |
| | |
| For example, to convert 16 bit to 8 bit <code>find_closest_palette_color()</code> may perform just a simple rounding
| |
| find_closest_palette_color(oldpixel) = oldpixel / 256
| |
| | |
| ==See also==
| |
| *[[Error diffusion]]
| |
| | |
| ==References==
| |
| *[http://www.visgraf.impa.br/Courses/ip00/proj/Dithering1/floyd_steinberg_dithering.html Floyd–Steinberg Dithering] (Graphics course project, Visgraf lab, Brazil)
| |
| *R.W. Floyd, L. Steinberg, ''An adaptive algorithm for spatial grey scale''. Proceedings of the Society of Information Display '''17''', 75–77 (1976).
| |
| | |
| ==External links==
| |
| *[http://www.2038bug.com/ptrans/ptrans.html PTRANS] Stand-alone ANSI-C programming language implementation.
| |
| *[http://michal.is/projects/image-dithering-in-matlab/ Matlab implementation]
| |
| | |
| {{DEFAULTSORT:Floyd-Steinberg dithering}}
| |
| [[Category:Image processing]]
| |
| [[Category:Articles with example pseudocode]]
| |
| [[Category:Computer graphics algorithms]]
| |
Hi there, I am Andrew Berryhill. The favorite hobby for him and his kids is to perform lacross and he would never give it up. My working day occupation is a travel agent. Some time in the past she chose to live in Alaska and her parents live close by.
My web-site love psychic