Skip to content

Instantly share code, notes, and snippets.

@kashimAstro
Created February 19, 2016 15:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kashimAstro/c26b3245d003e8acb5cb to your computer and use it in GitHub Desktop.
Save kashimAstro/c26b3245d003e8acb5cb to your computer and use it in GitHub Desktop.
pseudocode floyd steinberg
per ogni y dall'alto in basso
per ogni x da sinistra a destra
vecchio_pixel := pixel[x][y]
nuovo_pixel := trova_il_colore_della_tavolozza_più_vicino(vecchio_pixel)
pixel[x][y] := nuovo_pixel
quant_errore := vecchio_pixel - nuovo_pixel
pixel[x+1][y] := pixel[x+1][y] + 7/16 * quant_errore
pixel[x-1][y+1] := pixel[x-1][y+1] + 3/16 * quant_errore
pixel[x][y+1] := pixel[x][y+1] + 5/16 * quant_errore
pixel[x+1][y+1] := pixel[x+1][y+1] + 1/16 * quant_errore
//8BIT
trova_il_colore_della_tavolozza_più_vicino(vecchio_pixel) = (vecchio_pixel + 128) / 256
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment