{"id":856,"date":"2026-02-13T14:06:46","date_gmt":"2026-02-13T05:06:46","guid":{"rendered":"https:\/\/barbegenerativediary.com\/en\/?p=856"},"modified":"2026-02-13T14:06:46","modified_gmt":"2026-02-13T05:06:46","slug":"error-diffusionfloydsteinberg-atkinsonin","status":"publish","type":"post","link":"https:\/\/barbegenerativediary.com\/en\/tutorials\/error-diffusionfloydsteinberg-atkinsonin\/","title":{"rendered":"Error Diffusion (Floyd\u2013Steinberg \/ Atkinson) in Processing : From Basics to Levels"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><strong>Dithering<\/strong> is a classic image-processing technique used to make images appear smoother in environments where only a small number of colors or tonal levels can be displayed. In the previous article, the most fundamental form of dithering <strong>ordered dithering<\/strong> was introduced, along with a Processing implementation using a <strong>Bayer matrix<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this article, the focus shifts to the other major pillar of dithering: <strong>error diffusion<\/strong>. Two representative methods, <strong>Floyd\u2013Steinberg<\/strong> and the widely used <strong>Atkinson<\/strong> approach in artistic contexts, will be implemented in Processing, and their differences from ordered dithering will be clearly compared.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>The complete sample code for this article is available for download on Patreon.<\/strong><br>\u2615 <strong>Support my Work:) \/ <a href=\"https:\/\/www.patreon.com\/barbe_generative_diary\/membership\" target=\"_blank\" rel=\"noopener\" title=\"\">Coffee Supplier on Patreon<\/a><\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1. What is Error Diffusion?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Error diffusion is a dithering method that represents tonal gradation by <strong>propagating quantization errors<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In quantization such as black-and-white binarization, each pixel\u2019s brightness is ultimately rounded to one of only two values:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>0 (black)<\/li>\n\n\n\n<li>255 (white)<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">However, this rounding process always produces an <strong>error<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example, if the original brightness is <strong>180<\/strong>:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>rounding to white gives <strong>255<\/strong><\/li>\n\n\n\n<li>the error becomes <strong>180 &#8211; 255 = -75<\/strong><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Error diffusion does not discard this error. Instead, it distributes the error to nearby <strong>unprocessed pixels<\/strong>, so that the overall brightness stays closer to the original image.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2. Difference from Ordered Dithering<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The Ordered dithering method discussed in the previous article works like this:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>change the threshold depending on the pixel position<\/li>\n\n\n\n<li>repeat a threshold map (Bayer matrix) as a tiled pattern<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"1024\" height=\"576\" data-src=\"https:\/\/barbegenerativediary.com\/en\/wp-content\/uploads\/2026\/02\/Ordered-Dithering4.webp\" alt=\"\" class=\"wp-image-848 lazyload\" data-srcset=\"https:\/\/barbegenerativediary.com\/en\/wp-content\/uploads\/2026\/02\/Ordered-Dithering4.webp 1024w, https:\/\/barbegenerativediary.com\/en\/wp-content\/uploads\/2026\/02\/Ordered-Dithering4-300x169.webp 300w, https:\/\/barbegenerativediary.com\/en\/wp-content\/uploads\/2026\/02\/Ordered-Dithering4-768x432.webp 768w\" data-sizes=\"(max-width: 1024px) 100vw, 1024px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1024px; --smush-placeholder-aspect-ratio: 1024\/576;\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">In contrast, error diffusion has different characteristics:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>it does not use a threshold matrix<\/li>\n\n\n\n<li>each pixel\u2019s output affects the pixels that come next<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"1024\" height=\"576\" data-src=\"https:\/\/barbegenerativediary.com\/en\/wp-content\/uploads\/2026\/02\/f5d979694dbc6e461f3a35fb4117cc06.webp\" alt=\"\" class=\"wp-image-864 lazyload\" data-srcset=\"https:\/\/barbegenerativediary.com\/en\/wp-content\/uploads\/2026\/02\/f5d979694dbc6e461f3a35fb4117cc06.webp 1024w, https:\/\/barbegenerativediary.com\/en\/wp-content\/uploads\/2026\/02\/f5d979694dbc6e461f3a35fb4117cc06-300x169.webp 300w, https:\/\/barbegenerativediary.com\/en\/wp-content\/uploads\/2026\/02\/f5d979694dbc6e461f3a35fb4117cc06-768x432.webp 768w\" data-sizes=\"(max-width: 1024px) 100vw, 1024px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1024px; --smush-placeholder-aspect-ratio: 1024\/576;\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">As a result, the visible texture is not a regular repeating pattern.<br>Instead, it tends to look more like natural noise.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">However, as a side effect, error diffusion is more sensitive in animation or real-time rendering. The pattern can change from frame to frame more easily, which often creates a \u201cshimmering\u201d or \u201ccrawling\u201d look compared to Ordered dithering.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3. The Basic Steps of Error Diffusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Most error diffusion algorithms can be explained with the following flow:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Read the brightness of the source image<\/li>\n\n\n\n<li>Quantize the pixel (binarize or reduce to a small number of levels)<\/li>\n\n\n\n<li>Compute the error (original &#8211; quantized)<\/li>\n\n\n\n<li>Add the error to neighboring unprocessed pixels<\/li>\n\n\n\n<li>Move to the next pixel<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">The important point is that the algorithm needs a <strong>working buffer<\/strong> to store the values after error is added.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If errors are applied directly to Processing\u2019s pixels[], the code becomes harder to manage because of color formats and type conversions.<br>A clean approach is to store only brightness values in a float[].<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">4. What is Floyd\u2013Steinberg?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The most famous and fundamental error diffusion algorithm is <strong>Floyd\u2013Steinberg dithering<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"1024\" height=\"576\" data-src=\"https:\/\/barbegenerativediary.com\/en\/wp-content\/uploads\/2026\/02\/261407737e5bbc0eaa5fa2d19d9f59d6.webp\" alt=\"\" class=\"wp-image-865 lazyload\" data-srcset=\"https:\/\/barbegenerativediary.com\/en\/wp-content\/uploads\/2026\/02\/261407737e5bbc0eaa5fa2d19d9f59d6.webp 1024w, https:\/\/barbegenerativediary.com\/en\/wp-content\/uploads\/2026\/02\/261407737e5bbc0eaa5fa2d19d9f59d6-300x169.webp 300w, https:\/\/barbegenerativediary.com\/en\/wp-content\/uploads\/2026\/02\/261407737e5bbc0eaa5fa2d19d9f59d6-768x432.webp 768w\" data-sizes=\"(max-width: 1024px) 100vw, 1024px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1024px; --smush-placeholder-aspect-ratio: 1024\/576;\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Floyd\u2013Steinberg distributes the error to 4 neighboring pixels using fixed weights:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"1024\" height=\"337\" data-src=\"https:\/\/barbegenerativediary.com\/en\/wp-content\/uploads\/2026\/02\/f583013a0d499b2e71e5955f7580e508.png\" alt=\"\" class=\"wp-image-866 lazyload\" data-srcset=\"https:\/\/barbegenerativediary.com\/en\/wp-content\/uploads\/2026\/02\/f583013a0d499b2e71e5955f7580e508.png 1024w, https:\/\/barbegenerativediary.com\/en\/wp-content\/uploads\/2026\/02\/f583013a0d499b2e71e5955f7580e508-300x99.png 300w, https:\/\/barbegenerativediary.com\/en\/wp-content\/uploads\/2026\/02\/f583013a0d499b2e71e5955f7580e508-768x253.png 768w\" data-sizes=\"(max-width: 1024px) 100vw, 1024px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1024px; --smush-placeholder-aspect-ratio: 1024\/337;\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>right : 7\/16<\/li>\n\n\n\n<li>bottom-left : 3\/16<\/li>\n\n\n\n<li>bottom : 5\/16<\/li>\n\n\n\n<li>bottom-right : 1\/16<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">This method produces strong tonal representation and works well for photographic images.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">5. Processing Implementation (Floyd\u2013Steinberg \/ Binary)<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Below is a minimal Floyd\u2013Steinberg implementation.<br>As in the previous article, the structure is kept simple and readable, focusing on \u201ca version that works in Processing\u201d.<\/p>\n\n\n\n<pre><code class=\"language-processing\">\nvoid applyFloydSteinberg(PGraphics source) {\n  loadPixels();\n  source.loadPixels();\n\n  int w = width;\n  int h = height;\n\n  \/\/ Working brightness buffer (errors are accumulated here)\n  float[] buf = new float[w * h];\n\n  for (int i = 0; i < buf.length; i++) {\n    buf[i] = brightness(source.pixels[i]); \/\/ 0..255\n  }\n\n  for (int y = 0; y < h; y++) {\n    for (int x = 0; x < w; x++) {\n      int loc = x + y * w;\n\n      float oldV = buf[loc];\n      float newV = (oldV < 128) ? 0 : 255;\n\n      pixels[loc] = color(newV);\n\n      float err = oldV - newV;\n\n      \/\/ Diffuse error (with boundary checks)\n      addError(buf, x + 1, y,     w, h, err * 7.0\/16.0);\n      addError(buf, x - 1, y + 1, w, h, err * 3.0\/16.0);\n      addError(buf, x,     y + 1, w, h, err * 5.0\/16.0);\n      addError(buf, x + 1, y + 1, w, h, err * 1.0\/16.0);\n    }\n  }\n\n  updatePixels();\n}\n\nvoid addError(float[] buf, int x, int y, int w, int h, float v) {\n  if (x < 0 || x >= w || y < 0 || y >= h) return;\n  int loc = x + y * w;\n  buf[loc] = constrain(buf[loc] + v, 0, 255);\n}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">6. What is Happening in This Code? (Meaning of \u201cError\u201d)<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The key part of this implementation is these two lines:<\/p>\n\n\n\n<pre><code class=\"language-processing\">\nfloat err = oldV - newV;\naddError(..., err * ratio);\n<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>oldV is the current brightness including accumulated error<\/li>\n\n\n\n<li>newV is the quantized output value (black or white)<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The difference err is the information lost by quantization.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Floyd\u2013Steinberg spreads this lost information to surrounding pixels, so that the overall brightness stays closer to the original image.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">7. What is Atkinson?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Atkinson dithering<\/strong> is another well-known error diffusion method, especially popular in artistic and graphic contexts.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"1024\" height=\"576\" data-src=\"https:\/\/barbegenerativediary.com\/en\/wp-content\/uploads\/2026\/02\/Error-Diffusion_Atkinson-D.webp\" alt=\"\" class=\"wp-image-867 lazyload\" data-srcset=\"https:\/\/barbegenerativediary.com\/en\/wp-content\/uploads\/2026\/02\/Error-Diffusion_Atkinson-D.webp 1024w, https:\/\/barbegenerativediary.com\/en\/wp-content\/uploads\/2026\/02\/Error-Diffusion_Atkinson-D-300x169.webp 300w, https:\/\/barbegenerativediary.com\/en\/wp-content\/uploads\/2026\/02\/Error-Diffusion_Atkinson-D-768x432.webp 768w\" data-sizes=\"(max-width: 1024px) 100vw, 1024px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1024px; --smush-placeholder-aspect-ratio: 1024\/576;\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Atkinson distributes the error evenly (1\/8 each) to 6 neighboring pixels:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>right (x+1, y)<\/li>\n\n\n\n<li>right 2 pixels (x+2, y)<\/li>\n\n\n\n<li>bottom-left (x-1, y+1)<\/li>\n\n\n\n<li>bottom (x, y+1)<\/li>\n\n\n\n<li>bottom-right (x+1, y+1)<\/li>\n\n\n\n<li>2 rows down (x, y+2)<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Compared to Floyd\u2013Steinberg, the texture tends to feel lighter and more graphic, often closer to print-like patterns.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"1024\" height=\"337\" data-src=\"https:\/\/barbegenerativediary.com\/en\/wp-content\/uploads\/2026\/02\/Error-Diffusion_Atkinson-M.webp\" alt=\"\" class=\"wp-image-868 lazyload\" data-srcset=\"https:\/\/barbegenerativediary.com\/en\/wp-content\/uploads\/2026\/02\/Error-Diffusion_Atkinson-M.webp 1024w, https:\/\/barbegenerativediary.com\/en\/wp-content\/uploads\/2026\/02\/Error-Diffusion_Atkinson-M-300x99.webp 300w, https:\/\/barbegenerativediary.com\/en\/wp-content\/uploads\/2026\/02\/Error-Diffusion_Atkinson-M-768x253.webp 768w\" data-sizes=\"(max-width: 1024px) 100vw, 1024px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1024px; --smush-placeholder-aspect-ratio: 1024\/337;\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">8. Processing Implementation (Atkinson \/ Binary)<\/h2>\n\n\n\n<pre><code class=\"language-processing\">\nvoid applyAtkinson(PGraphics source) {\n  loadPixels();\n  source.loadPixels();\n\n  int w = width;\n  int h = height;\n\n  float[] buf = new float[w * h];\n  for (int i = 0; i < buf.length; i++) {\n    buf[i] = brightness(source.pixels[i]); \/\/ 0..255\n  }\n\n  for (int y = 0; y < h; y++) {\n    for (int x = 0; x < w; x++) {\n      int loc = x + y * w;\n\n      float oldV = buf[loc];\n      float newV = (oldV < 128) ? 0 : 255;\n\n      pixels[loc] = color(newV);\n\n      float err = oldV - newV;\n      float e = err \/ 8.0;\n\n      addError(buf, x + 1, y,     w, h, e);\n      addError(buf, x + 2, y,     w, h, e);\n      addError(buf, x - 1, y + 1, w, h, e);\n      addError(buf, x,     y + 1, w, h, e);\n      addError(buf, x + 1, y + 1, w, h, e);\n      addError(buf, x,     y + 2, w, h, e);\n    }\n  }\n\n  updatePixels();\n}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">9. Difference Between Floyd\u2013Steinberg and Atkinson<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Both are error diffusion methods, but the distribution patterns are different, which changes the visual characteristics.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Floyd\u2013Steinberg<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>strong tonal representation<\/li>\n\n\n\n<li>fine-grained texture, good for photos<\/li>\n\n\n\n<li>dark areas tend to be preserved<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Atkinson<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>lighter texture, good for graphics<\/li>\n\n\n\n<li>stronger contrast<\/li>\n\n\n\n<li>the image often looks slightly more \u201corganized\u201d<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">10. Extending to Multiple Levels (Not Only Black\/White)<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">So far, the output has been fixed to 2 levels: black or white.<br>However, error diffusion can also be extended to multi-level quantization, just like Ordered dithering.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">levels means the number of quantization steps (how many brightness values can be output).<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>levels = 2 \u2192 binary (0 \/ 255)<\/li>\n\n\n\n<li>levels = 4 \u2192 4 levels (0 \/ 85 \/ 170 \/ 255)<\/li>\n\n\n\n<li>levels = 8 \u2192 8 levels<\/li>\n\n\n\n<li>levels = 16 \u2192 16 levels<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The core structure remains the same: diffuse the error produced by quantization Only the quantization step is replaced with multi-level rounding.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">11. Processing Implementation (Levels Version)<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Below are levels versions of Floyd\u2013Steinberg and Atkinson.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Quantization function (0..255 \u2192 nearest level)<\/h3>\n\n\n\n<pre><code class=\"language-processing\">\nfloat quantizeLevels(float v, int levels) {\n  float step = 255.0 \/ (levels - 1);\n  return round(v \/ step) * step;\n}\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Floyd\u2013Steinberg (levels)<\/h3>\n\n\n\n<pre><code class=\"language-processing\">\nvoid applyFloydSteinbergLevels(PGraphics source, int levels) {\n  if (levels < 2) return;\n\n  loadPixels();\n  source.loadPixels();\n\n  int w = width;\n  int h = height;\n\n  float[] buf = new float[w * h];\n  for (int i = 0; i < buf.length; i++) {\n    buf[i] = brightness(source.pixels[i]); \/\/ 0..255\n  }\n\n  for (int y = 0; y < h; y++) {\n    for (int x = 0; x < w; x++) {\n      int loc = x + y * w;\n\n      float oldV = buf[loc];\n      float newV = quantizeLevels(oldV, levels);\n\n      pixels[loc] = color(newV);\n\n      float err = oldV - newV;\n\n      addError(buf, x + 1, y,     w, h, err * 7.0\/16.0);\n      addError(buf, x - 1, y + 1, w, h, err * 3.0\/16.0);\n      addError(buf, x,     y + 1, w, h, err * 5.0\/16.0);\n      addError(buf, x + 1, y + 1, w, h, err * 1.0\/16.0);\n    }\n  }\n\n  updatePixels();\n}\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Atkinson (levels)<\/h3>\n\n\n\n<pre><code class=\"language-processing\">\nvoid applyAtkinsonLevels(PGraphics source, int levels) {\n  if (levels < 2) return;\n\n  loadPixels();\n  source.loadPixels();\n\n  int w = width;\n  int h = height;\n\n  float[] buf = new float[w * h];\n  for (int i = 0; i < buf.length; i++) {\n    buf[i] = brightness(source.pixels[i]); \/\/ 0..255\n  }\n\n  for (int y = 0; y < h; y++) {\n    for (int x = 0; x < w; x++) {\n      int loc = x + y * w;\n\n      float oldV = buf[loc];\n      float newV = quantizeLevels(oldV, levels);\n\n      pixels[loc] = color(newV);\n\n      float err = oldV - newV;\n      float e = err \/ 8.0;\n\n      addError(buf, x + 1, y,     w, h, e);\n      addError(buf, x + 2, y,     w, h, e);\n      addError(buf, x - 1, y + 1, w, h, e);\n      addError(buf, x,     y + 1, w, h, e);\n      addError(buf, x + 1, y + 1, w, h, e);\n      addError(buf, x,     y + 2, w, h, e);\n    }\n  }\n\n  updatePixels();\n}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">12. When to Use Ordered Dithering vs Error Diffusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">As a practical guideline:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>for video \/ real-time stability \u2192 <strong>Ordered dithering<\/strong><\/li>\n\n\n\n<li>for photo-like gradation \u2192 <strong>Floyd\u2013Steinberg<\/strong><\/li>\n\n\n\n<li>for graphic texture \/ retro feeling \u2192 <strong>Atkinson<\/strong><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">In Processing-based artwork, dithering can be treated not only as image processing, but also as a method for generating texture. In that context, Atkinson is especially effective.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">13. Error Diffusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This article introduced the second major family of dithering algorithms: <strong>Error diffusion<\/strong>, implemented in Processing.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>error diffusion represents gradation by distributing quantization errors<\/li>\n\n\n\n<li>Floyd\u2013Steinberg produces strong, photographic dithering<\/li>\n\n\n\n<li>Atkinson produces lighter, graphic dithering<\/li>\n\n\n\n<li>error diffusion is more likely to shimmer in animation than ordered dithering<\/li>\n\n\n\n<li>both methods can be extended to multi-level quantization using levels<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">14. Work Example | Sound visualization<\/h2>\n\n\n\n<blockquote class=\"instagram-media\" data-instgrm-permalink=\"https:\/\/www.instagram.com\/reel\/DUqCf2tk1Ev\/?utm_source=ig_embed&amp;utm_campaign=loading\" data-instgrm-version=\"14\" style=\" background:#FFF; border:0; border-radius:3px; box-shadow:0 0 1px 0 rgba(0,0,0,0.5),0 1px 10px 0 rgba(0,0,0,0.15); margin: 1px; max-width:540px; min-width:326px; padding:0; width:99.375%; width:-webkit-calc(100% - 2px); width:calc(100% - 2px);\"><div style=\"padding:16px;\"> <a href=\"https:\/\/www.instagram.com\/reel\/DUqCf2tk1Ev\/?utm_source=ig_embed&amp;utm_campaign=loading\" style=\" background:#FFFFFF; line-height:0; padding:0 0; text-align:center; text-decoration:none; width:100%;\" target=\"_blank\"> <div style=\" display: flex; flex-direction: row; align-items: center;\"> <div style=\"background-color: #F4F4F4; border-radius: 50%; flex-grow: 0; height: 40px; margin-right: 14px; width: 40px;\"><\/div> <div style=\"display: flex; flex-direction: column; flex-grow: 1; justify-content: center;\"> <div style=\" background-color: #F4F4F4; border-radius: 4px; flex-grow: 0; height: 14px; margin-bottom: 6px; width: 100px;\"><\/div> <div style=\" background-color: #F4F4F4; border-radius: 4px; flex-grow: 0; height: 14px; width: 60px;\"><\/div><\/div><\/div><div style=\"padding: 19% 0;\"><\/div> <div style=\"display:block; height:50px; margin:0 auto 12px; width:50px;\"><svg width=\"50px\" height=\"50px\" viewBox=\"0 0 60 60\" version=\"1.1\" xmlns=\"https:\/\/www.w3.org\/2000\/svg\" xmlns:xlink=\"https:\/\/www.w3.org\/1999\/xlink\"><g stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\"><g transform=\"translate(-511.000000, -20.000000)\" fill=\"#000000\"><g><path d=\"M556.869,30.41 C554.814,30.41 553.148,32.076 553.148,34.131 C553.148,36.186 554.814,37.852 556.869,37.852 C558.924,37.852 560.59,36.186 560.59,34.131 C560.59,32.076 558.924,30.41 556.869,30.41 M541,60.657 C535.114,60.657 530.342,55.887 530.342,50 C530.342,44.114 535.114,39.342 541,39.342 C546.887,39.342 551.658,44.114 551.658,50 C551.658,55.887 546.887,60.657 541,60.657 M541,33.886 C532.1,33.886 524.886,41.1 524.886,50 C524.886,58.899 532.1,66.113 541,66.113 C549.9,66.113 557.115,58.899 557.115,50 C557.115,41.1 549.9,33.886 541,33.886 M565.378,62.101 C565.244,65.022 564.756,66.606 564.346,67.663 C563.803,69.06 563.154,70.057 562.106,71.106 C561.058,72.155 560.06,72.803 558.662,73.347 C557.607,73.757 556.021,74.244 553.102,74.378 C549.944,74.521 548.997,74.552 541,74.552 C533.003,74.552 532.056,74.521 528.898,74.378 C525.979,74.244 524.393,73.757 523.338,73.347 C521.94,72.803 520.942,72.155 519.894,71.106 C518.846,70.057 518.197,69.06 517.654,67.663 C517.244,66.606 516.755,65.022 516.623,62.101 C516.479,58.943 516.448,57.996 516.448,50 C516.448,42.003 516.479,41.056 516.623,37.899 C516.755,34.978 517.244,33.391 517.654,32.338 C518.197,30.938 518.846,29.942 519.894,28.894 C520.942,27.846 521.94,27.196 523.338,26.654 C524.393,26.244 525.979,25.756 528.898,25.623 C532.057,25.479 533.004,25.448 541,25.448 C548.997,25.448 549.943,25.479 553.102,25.623 C556.021,25.756 557.607,26.244 558.662,26.654 C560.06,27.196 561.058,27.846 562.106,28.894 C563.154,29.942 563.803,30.938 564.346,32.338 C564.756,33.391 565.244,34.978 565.378,37.899 C565.522,41.056 565.552,42.003 565.552,50 C565.552,57.996 565.522,58.943 565.378,62.101 M570.82,37.631 C570.674,34.438 570.167,32.258 569.425,30.349 C568.659,28.377 567.633,26.702 565.965,25.035 C564.297,23.368 562.623,22.342 560.652,21.575 C558.743,20.834 556.562,20.326 553.369,20.18 C550.169,20.033 549.148,20 541,20 C532.853,20 531.831,20.033 528.631,20.18 C525.438,20.326 523.257,20.834 521.349,21.575 C519.376,22.342 517.703,23.368 516.035,25.035 C514.368,26.702 513.342,28.377 512.574,30.349 C511.834,32.258 511.326,34.438 511.181,37.631 C511.035,40.831 511,41.851 511,50 C511,58.147 511.035,59.17 511.181,62.369 C511.326,65.562 511.834,67.743 512.574,69.651 C513.342,71.625 514.368,73.296 516.035,74.965 C517.703,76.634 519.376,77.658 521.349,78.425 C523.257,79.167 525.438,79.673 528.631,79.82 C531.831,79.965 532.853,80.001 541,80.001 C549.148,80.001 550.169,79.965 553.369,79.82 C556.562,79.673 558.743,79.167 560.652,78.425 C562.623,77.658 564.297,76.634 565.965,74.965 C567.633,73.296 568.659,71.625 569.425,69.651 C570.167,67.743 570.674,65.562 570.82,62.369 C570.966,59.17 571,58.147 571,50 C571,41.851 570.966,40.831 570.82,37.631\"><\/path><\/g><\/g><\/g><\/svg><\/div><div style=\"padding-top: 8px;\"> <div style=\" color:#3897f0; font-family:Arial,sans-serif; font-size:14px; font-style:normal; font-weight:550; line-height:18px;\">View this post on Instagram<\/div><\/div><div style=\"padding: 12.5% 0;\"><\/div> <div style=\"display: flex; flex-direction: row; margin-bottom: 14px; align-items: center;\"><div> <div style=\"background-color: #F4F4F4; border-radius: 50%; height: 12.5px; width: 12.5px; transform: translateX(0px) translateY(7px);\"><\/div> <div style=\"background-color: #F4F4F4; height: 12.5px; transform: rotate(-45deg) translateX(3px) translateY(1px); width: 12.5px; flex-grow: 0; margin-right: 14px; margin-left: 2px;\"><\/div> <div style=\"background-color: #F4F4F4; border-radius: 50%; height: 12.5px; width: 12.5px; transform: translateX(9px) translateY(-18px);\"><\/div><\/div><div style=\"margin-left: 8px;\"> <div style=\" background-color: #F4F4F4; border-radius: 50%; flex-grow: 0; height: 20px; width: 20px;\"><\/div> <div style=\" width: 0; height: 0; border-top: 2px solid transparent; border-left: 6px solid #f4f4f4; border-bottom: 2px solid transparent; transform: translateX(16px) translateY(-4px) rotate(30deg)\"><\/div><\/div><div style=\"margin-left: auto;\"> <div style=\" width: 0px; border-top: 8px solid #F4F4F4; border-right: 8px solid transparent; transform: translateY(16px);\"><\/div> <div style=\" background-color: #F4F4F4; flex-grow: 0; height: 12px; width: 16px; transform: translateY(-4px);\"><\/div> <div style=\" width: 0; height: 0; border-top: 8px solid #F4F4F4; border-left: 8px solid transparent; transform: translateY(-4px) translateX(8px);\"><\/div><\/div><\/div> <div style=\"display: flex; flex-direction: column; flex-grow: 1; justify-content: center; margin-bottom: 24px;\"> <div style=\" background-color: #F4F4F4; border-radius: 4px; flex-grow: 0; height: 14px; margin-bottom: 6px; width: 224px;\"><\/div> <div style=\" background-color: #F4F4F4; border-radius: 4px; flex-grow: 0; height: 14px; width: 144px;\"><\/div><\/div><\/a><p style=\" color:#c9c8cd; font-family:Arial,sans-serif; font-size:14px; line-height:17px; margin-bottom:0; margin-top:8px; overflow:hidden; padding:8px 0 7px; text-align:center; text-overflow:ellipsis; white-space:nowrap;\"><a href=\"https:\/\/www.instagram.com\/reel\/DUqCf2tk1Ev\/?utm_source=ig_embed&amp;utm_campaign=loading\" style=\" color:#c9c8cd; font-family:Arial,sans-serif; font-size:14px; font-style:normal; font-weight:normal; line-height:17px; text-decoration:none;\" target=\"_blank\">A post shared by bgd peco (@barbe_generative_diary)<\/a><\/p><\/div><\/blockquote>\n<script async src=\"\/\/www.instagram.com\/embed.js\"><\/script>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"MinkowskiDistance-05\"><em>Recommended Book \/ Generative art for beginner<\/em><\/h2>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" width=\"1024\" height=\"576\" data-src=\"https:\/\/barbegenerativediary.com\/en\/wp-content\/uploads\/2023\/09\/GenerativeArtProcessing.webp\" alt=\"\" class=\"wp-image-327 lazyload\" data-srcset=\"https:\/\/barbegenerativediary.com\/en\/wp-content\/uploads\/2023\/09\/GenerativeArtProcessing.webp 1024w, https:\/\/barbegenerativediary.com\/en\/wp-content\/uploads\/2023\/09\/GenerativeArtProcessing-300x169.webp 300w, https:\/\/barbegenerativediary.com\/en\/wp-content\/uploads\/2023\/09\/GenerativeArtProcessing-768x432.webp 768w\" data-sizes=\"(max-width: 1024px) 100vw, 1024px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1024px; --smush-placeholder-aspect-ratio: 1024\/576;\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><a href=\"https:\/\/amzn.to\/3rBeaOZ\" target=\"_blank\" rel=\"noreferrer noopener\">Generative Art: A Practical Guide Using Processing<\/a><a href=\"https:\/\/amzn.to\/45Xzptl\" target=\"_blank\" rel=\"noreferrer noopener\">&nbsp;<\/a>\u2013 Matt Pearson<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Generative Art presents both the techniques and the beauty of algorithmic art. In it, you\u2019ll find dozens of high-quality examples of generative art, along with the specific steps the author followed to create each unique piece using the Processing programming language. The book includes concise tutorials for each of the technical components required to create the book\u2019s images, and it offers countless suggestions for how you can combine and reuse the various techniques to create your own works.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Purchase of the print book comes with an offer of a free PDF, ePub, and Kindle eBook from Manning. Also available is all code from the book.<br>\u2014\u2013<br>\u25ba&nbsp;<strong><a href=\"https:\/\/amzn.to\/3rBeaOZ\" target=\"_blank\" rel=\"noreferrer noopener\">Generative Art: A Practical Guide Using Processing<\/a><\/strong>&nbsp;\u2013 Matt Pearson<br>Publication date: 2011. July<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&nbsp;<strong>Support my Website<\/strong><br>By using our affiliate links, you\u2019re helping my content and allows me to keep creating valuable articles. I appreciate it so much:)<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"BGD_SOUNDS\"><em>BGD_SOUNDS (barbe_generative_diary SOUNDS)<\/em><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">barbe_generative_diary SOUNDS will start sharing and selling a variety of field recordings collected for use in my artwork \u201cSound Visualization\u201d experiments. All sounds are royalty-free.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/barbegenerativediary.bandcamp.com\/\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>Link \/ BGD_SOUNDS on bandcamp<\/strong><\/a><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" width=\"1024\" height=\"731\" data-src=\"https:\/\/barbegenerativediary.com\/en\/wp-content\/uploads\/2024\/07\/240801_bandcamp-top-BGD_SOUNDS.webp\" alt=\"\" class=\"wp-image-554 lazyload\" data-srcset=\"https:\/\/barbegenerativediary.com\/en\/wp-content\/uploads\/2024\/07\/240801_bandcamp-top-BGD_SOUNDS.webp 1024w, https:\/\/barbegenerativediary.com\/en\/wp-content\/uploads\/2024\/07\/240801_bandcamp-top-BGD_SOUNDS-300x214.webp 300w, https:\/\/barbegenerativediary.com\/en\/wp-content\/uploads\/2024\/07\/240801_bandcamp-top-BGD_SOUNDS-768x548.webp 768w\" data-sizes=\"(max-width: 1024px) 100vw, 1024px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1024px; --smush-placeholder-aspect-ratio: 1024\/731;\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Error diffusion is a dithering technique that distributes quantization error to surrounding unprocessed pixels as it proceeds, allowing smooth brightness gradients even with a limited number of tonal levels. Unlike threshold-matrix methods, it tends to produce a more natural, noise-like texture.<\/p>\n","protected":false},"author":1,"featured_media":863,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15,13],"tags":[],"class_list":["post-856","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-processing-tutorials","category-tutorials"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/barbegenerativediary.com\/en\/wp-json\/wp\/v2\/posts\/856","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/barbegenerativediary.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/barbegenerativediary.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/barbegenerativediary.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/barbegenerativediary.com\/en\/wp-json\/wp\/v2\/comments?post=856"}],"version-history":[{"count":9,"href":"https:\/\/barbegenerativediary.com\/en\/wp-json\/wp\/v2\/posts\/856\/revisions"}],"predecessor-version":[{"id":871,"href":"https:\/\/barbegenerativediary.com\/en\/wp-json\/wp\/v2\/posts\/856\/revisions\/871"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/barbegenerativediary.com\/en\/wp-json\/wp\/v2\/media\/863"}],"wp:attachment":[{"href":"https:\/\/barbegenerativediary.com\/en\/wp-json\/wp\/v2\/media?parent=856"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/barbegenerativediary.com\/en\/wp-json\/wp\/v2\/categories?post=856"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/barbegenerativediary.com\/en\/wp-json\/wp\/v2\/tags?post=856"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}