{
 "id": "kuwahara-filter",
 "title": "Kuwahara filter",
 "aliases": [],
 "domain": "npr",
 "subdomain": "painterly image filters",
 "stage": "post",
 "realtime": "realtime",
 "platforms": [
  "webgl2",
  "webgpu",
  "desktop-gpu",
  "mobile-gpu",
  "unity",
  "unreal",
  "godot",
  "python"
 ],
 "year_introduced": 1976,
 "inputs": [
  "ldr-image"
 ],
 "outputs": [
  "ldr-image"
 ],
 "style": "stylized",
 "dynamic": "both",
 "summary": "Edge-preserving smoothing that splits each pixel's neighbourhood into four overlapping sub-windows and outputs the mean of the one with the lowest variance, giving a flat, oil-paint look.",
 "how_it_works": "For every pixel, the square neighbourhood is divided into four quadrants that all share the centre pixel. For each quadrant, compute the mean colour and the variance of brightness. The output is the mean of the quadrant with the smallest variance. Flat regions get averaged strongly, while pixels on a boundary choose the quadrant lying entirely on one side, so edges are not blurred. The larger the radius, the more paint-like the result. Because every pixel computes four windows, cost grows with radius squared, and implementations often use summed-area tables, separable approximations or reduced taps to stay real-time. The blocky look from fixed square windows is the motivation for the anisotropic variant.",
 "when_to_use": "Choose it for quick oil-painting or poster-like post-processing of any frame, including 3D renders. Prefer `anisotropic-kuwahara` when blocky square artefacts are visible and you can afford a structure tensor pass. Prefer `posterization` for a colour-count reduction without spatial smoothing.",
 "cost": {
  "class": "medium",
  "notes": "Cost scales with window area; a radius of 4 to 8 at 1080p is a medium-cost full-screen pass without optimization."
 },
 "failure_modes": [
  "Square window produces visible blocky, boxy shapes at larger radii",
  "Noisy flat regions can flip between quadrants and create speckle",
  "Can wash out thin lines and small high-contrast details",
  "Colour banding and temporal shimmer when the winning quadrant switches between frames"
 ],
 "sources": [
  {
   "role": "primary",
   "key": "doi:10.1111/j.1467-8659.2009.01574.x",
   "type": "paper",
   "title": "Image and Video Abstraction by Anisotropic Kuwahara Filtering",
   "authors": [
    "Jan Eric Kyprianidis",
    "Henry Kang",
    "Jürgen Döllner"
   ],
   "year": 2009,
   "venue": "Computer Graphics Forum",
   "url": "https://doi.org/10.1111/j.1467-8659.2009.01574.x",
   "ids": {
    "doi": "10.1111/j.1467-8659.2009.01574.x"
   },
   "license": null,
   "extra": {
    "csl_type": "journal-article"
   },
   "provenance": {
    "title": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1111/j.1467-8659.2009.01574.x",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1111/j.1467-8659.2009.01574.x",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1111/j.1467-8659.2009.01574.x",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1111/j.1467-8659.2009.01574.x",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1111/j.1467-8659.2009.01574.x",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": 1,
   "__bib": "kyprianidis2009image"
  },
  {
   "role": "implementation",
   "key": "gh:garrettgunnell/post-processing",
   "type": "code",
   "title": "GarrettGunnell/Post-Processing",
   "description": "My Unity post processing pipeline and shaders",
   "authors": [
    "GarrettGunnell"
   ],
   "year": 2022,
   "venue": "GitHub",
   "url": "https://github.com/GarrettGunnell/Post-Processing",
   "ids": {
    "repo": "GarrettGunnell/Post-Processing"
   },
   "license": "MIT",
   "extra": {
    "stars": 834,
    "stars_checked": "2026-11-29",
    "archived": false,
    "fork": false,
    "pushed_at": "2024-06-30T11:16:48Z",
    "language": "ShaderLab",
    "homepage": null,
    "license_name": "MIT License"
   },
   "provenance": {
    "title": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/GarrettGunnell/Post-Processing",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/GarrettGunnell/Post-Processing",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/GarrettGunnell/Post-Processing",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/GarrettGunnell/Post-Processing",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/GarrettGunnell/Post-Processing",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "license": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/GarrettGunnell/Post-Processing",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": null,
   "__bib": "garrettgunnell2022garrettgunnell"
  },
  {
   "role": "implementation",
   "key": "gh:noxtgm/kuwahara-filter",
   "type": "code",
   "title": "noxtgm/kuwahara-filter",
   "description": "Kuwahara filter for Unreal Engine's post process component.",
   "authors": [
    "noxtgm"
   ],
   "year": 2023,
   "venue": "GitHub",
   "url": "https://github.com/noxtgm/kuwahara-filter",
   "ids": {
    "repo": "noxtgm/kuwahara-filter"
   },
   "license": "CC0-1.0",
   "extra": {
    "stars": 27,
    "stars_checked": "2026-11-29",
    "archived": false,
    "fork": false,
    "pushed_at": "2026-04-20T22:58:49Z",
    "language": null,
    "homepage": null,
    "license_name": "Creative Commons Zero v1.0 Universal"
   },
   "provenance": {
    "title": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/noxtgm/kuwahara-filter",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/noxtgm/kuwahara-filter",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/noxtgm/kuwahara-filter",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/noxtgm/kuwahara-filter",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/noxtgm/kuwahara-filter",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "license": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/noxtgm/kuwahara-filter",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": null,
   "__bib": "noxtgm2023noxtgm"
  }
 ],
 "presets": [
  {
   "id": "kuwahara-procedural-r5",
   "title": "Classic Kuwahara, radius 5, procedural image",
   "runtime": "glsl-fragment",
   "params": {
    "radius": 5
   },
   "code": "// GLSL ES 3.0, Shadertoy-style: classic 4-quadrant Kuwahara on a procedural image\nconst int   R = 5;        // quadrant radius in pixels\nconst float SPLIT = 0.5;  // left half shows the filtered result, right half the source (set 0.0 for all filtered)\n\nvec3 img(vec2 p){\n  vec2 q = p / iResolution.y;\n  float n = sin(q.x*17.0)*sin(q.y*13.0) + 0.5*sin(q.x*41.0 + q.y*29.0);\n  float d = length(q - vec2(0.9, 0.5));\n  vec3 c = 0.5 + 0.5*cos(6.2831*(vec3(0.0,0.33,0.67) + n*0.25 + d*1.4));\n  c += 0.18*sin(q.x*400.0)*sin(q.y*380.0);          // high-frequency grain to be removed\n  return c;\n}\nvoid mainImage(out vec4 fragColor, in vec2 fragCoord){\n  if(fragCoord.x / iResolution.x > SPLIT){ fragColor = vec4(clamp(img(fragCoord),0.0,1.0),1.0); return; }\n  vec3 bestMean = vec3(0.0);\n  float bestVar = 1e9;\n  for(int k=0;k<4;k++){\n    vec2 s = vec2((k & 1) == 0 ? 1.0 : -1.0, (k & 2) == 0 ? 1.0 : -1.0);\n    vec3 sum = vec3(0.0); float sum2 = 0.0;\n    for(int j=0;j<=R;j++){\n      for(int i=0;i<=R;i++){\n        vec3 c = img(fragCoord + vec2(float(i), float(j))*s);\n        sum += c;\n        float l = dot(c, vec3(0.299,0.587,0.114));\n        sum2 += l*l;\n      }\n    }\n    float N = float((R+1)*(R+1));\n    vec3 m = sum / N;\n    float ml = dot(m, vec3(0.299,0.587,0.114));\n    float v = sum2/N - ml*ml;\n    if(v < bestVar){ bestVar = v; bestMean = m; }\n  }\n  fragColor = vec4(clamp(bestMean, 0.0, 1.0), 1.0);\n}\n",
   "basis": "original",
   "license_note": "written for this index",
   "execution_fidelity": "faithful-pass",
   "proof": {
    "kind": "rendered",
    "label": "rendered 2026-11-29",
    "ok": true,
    "proof": {
     "ok": true,
     "technique": "kuwahara-filter",
     "runtime": "glsl-fragment",
     "checked_at": "2026-11-29T15:51:50.471Z",
     "renderer": "Chromium 145.0.7632.6 headless, WebGL2 via ANGLE/SwiftShader, 512×512, iTime=1.5",
     "stats": {
      "mean": 0.4941,
      "std": 0.2119,
      "unique_colors": 2280
     },
     "image": "/specimens/kuwahara-procedural-r5.webp",
     "reason": null
    }
   }
  }
 ],
 "related": [
  "anisotropic-kuwahara",
  "posterization",
  "painterly-curved-brush-strokes"
 ],
 "extends": [],
 "supersedes": [],
 "combines_with": [
  {
   "id": "anisotropic-kuwahara",
   "why": "Classic filter is the baseline; the anisotropic one replaces its square windows."
  },
  {
   "id": "screen-space-edge-outline",
   "why": "Painterly colour from Kuwahara plus crisp edge lines from G-buffer edges."
  }
 ],
 "provenance": {
  "prose": "original text written for this index (research draft, editorially reviewed)",
  "sources_verified_at": "2026-11-29T15:51:27.588Z",
  "draft": "data/drafts/npr/kuwahara-filter.json"
 },
 "solves": [
  "want an oil painting look on a render",
  "photo should look like a flat poster-style painting",
  "smooth colour regions but keep edges sharp",
  "cheap painterly look as a post-process",
  "reduce detail without blurring edges"
 ],
 "authority": "Kyprianidis et al., 2009",
 "url": "https://texelatlas.vercel.app/t/kuwahara-filter/",
 "execution_fidelity": "faithful-pass",
 "fidelity_label": "Faithful Pass",
 "benchmark_eligible": true,
 "gpu_weight": {
  "weight_x": 54.23,
  "tier": "heavy",
  "p50_ms": 1.7843,
  "p95_ms": 1.9186,
  "baseline_p50_ms": 0.0329,
  "gpu": "Tesla T4/PCIe/SSE2",
  "resolution": "1920x1080",
  "method": "opengl-timer-query",
  "frames": 40,
  "preset_id": "kuwahara-procedural-r5",
  "execution_fidelity": "faithful-pass",
  "fidelity_label": "Faithful Pass",
  "benchmark_eligible": true,
  "generated_at": "2026-11-30T21:07:47Z",
  "l4": {
   "weight_x": 46.31,
   "tier": "heavy",
   "p50_ms": 0.7364,
   "p95_ms": 0.7392,
   "speedup_x": 2.42,
   "gpu": "NVIDIA L4/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0159
  },
  "a100": {
   "weight_x": 36.22,
   "tier": "heavy",
   "p50_ms": 1.0432,
   "p95_ms": 1.0524,
   "speedup_x": 1.71,
   "gpu": "NVIDIA A100-SXM4-40GB/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0288
  }
 }
}