{
 "id": "anisotropic-kuwahara",
 "title": "Anisotropic Kuwahara filter",
 "aliases": [],
 "domain": "npr",
 "subdomain": "painterly image filters",
 "stage": "post",
 "realtime": "realtime",
 "platforms": [
  "webgl2",
  "webgpu",
  "desktop-gpu",
  "mobile-gpu",
  "unity",
  "unreal",
  "godot"
 ],
 "year_introduced": 2009,
 "inputs": [
  "ldr-image"
 ],
 "outputs": [
  "ldr-image"
 ],
 "style": "stylized",
 "dynamic": "both",
 "summary": "Kuwahara filtering with elliptical, direction-aligned sectors driven by a structure tensor, producing smooth painterly strokes that follow image features instead of axis-aligned blocks.",
 "how_it_works": "First, a structure tensor is estimated per pixel from Sobel gradients and smoothed with a Gaussian. Its eigenvectors give the local feature orientation and its eigenvalues give anisotropy. Each pixel then samples an ellipse oriented along that direction, divided into eight sectors weighted by a smooth polynomial or Gaussian rather than a hard window. For each sector it computes a weighted mean and variance, and blends the sector means with weights that favour low-variance sectors, instead of a hard winner-take-all choice. The soft weighting removes the discontinuities of the classic filter, and the oriented ellipses make edges follow brush-like curves. A multi-scale extension further preserves large-scale structure.",
 "when_to_use": "Choose it when you want convincing oil-paint or watercolour-like abstraction from a rendered frame and can budget two or three passes. Prefer `kuwahara-filter` for the cheapest option. Prefer `painterly-curved-brush-strokes` when you need visible individual brush strokes with direction and texture rather than a smooth filter.",
 "cost": {
  "class": "heavy",
  "notes": "Structure tensor passes plus a heavy sector-sampling pass; medium to heavy depending on radius."
 },
 "failure_modes": [
  "Flickers on animated scenes because the structure tensor changes frame to frame",
  "Over-smoothing removes small details and faces unless strength is limited",
  "Orientation is unstable in flat regions, causing swirls",
  "Expensive at large radius without separable approximation or mip-based tricks"
 ],
 "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": "primary",
   "key": "doi:10.1145/2024676.2024686",
   "type": "paper",
   "title": "Image and video abstraction by multi-scale anisotropic Kuwahara filtering",
   "authors": [
    "Jan Eric Kyprianidis"
   ],
   "year": 2011,
   "venue": "Proceedings of the ACM SIGGRAPH/Eurographics Symposium on Non-Photorealistic Animation and Rendering",
   "url": "https://doi.org/10.1145/2024676.2024686",
   "ids": {
    "doi": "10.1145/2024676.2024686"
   },
   "license": null,
   "extra": {
    "csl_type": "proceedings-article"
   },
   "provenance": {
    "title": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/2024676.2024686",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/2024676.2024686",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/2024676.2024686",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/2024676.2024686",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/2024676.2024686",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": 1,
   "__bib": "kyprianidis2011image"
  },
  {
   "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"
  }
 ],
 "presets": [
  {
   "id": "anisotropic-kuwahara-specimen",
   "title": "Left: noisy source. Right: anisotropic Kuwahara, 8 elliptical sectors oriented by the structure tensor",
   "runtime": "glsl-fragment",
   "params": {
    "RAD": 10,
    "QEXP": 4,
    "ALPHA": 1
   },
   "code": "float hash(vec2 c){uvec2 u=uvec2(ivec2(floor(c)));uint h=u.x*1597334673u^u.y*3812015801u;h^=h>>15;h*=2246822519u;h^=h>>13;h*=3266489917u;h^=h>>16;return float(h)*(1./4294967296.);}\nfloat lum(vec3 c){return dot(c,vec3(.2126,.7152,.0722));}\nvec3 gam(vec3 c){return pow(clamp(c,0.,1.),vec3(1./2.2));}\nvec3 img(vec2 p){\n  vec3 c=mix(vec3(.12,.18,.34),vec3(.95,.72,.45),clamp(p.y+.5,0.,1.));\n  vec2 q=p-vec2(-.03,.14); float rr=.16; float d=length(q)-rr;\n  vec3 n=normalize(vec3(q/rr,sqrt(max(1.-dot(q,q)/(rr*rr),0.))));\n  float l=clamp(dot(n,normalize(vec3(-.5,.6,.6))),0.,1.);\n  c=mix(c,vec3(.85,.26,.2)*(.18+.9*l),smoothstep(.002,-.002,d));\n  vec2 r=p-vec2(0.,-.2);\n  if(abs(r.x)<.2&&abs(r.y)<.09) c=mix(vec3(.1,.35,.3),vec3(.93,.92,.85),smoothstep(-.3,.3,sin(r.x*340.+r.y*90.)));\n  if(p.y<-.34&&p.y>-.42){ vec3 h=.5+.5*cos(6.2832*((p.x+.25)*2.+vec3(0.,.33,.67))); c=h; }\n  c=mix(c,vec3(.97,.85,.2),smoothstep(.003,-.003,abs(p.x-.17)-.025)*step(.0,p.y)*step(p.y,.4));\n  return c;\n}\n\nconst float RAD=10.0; // P\nconst float QEXP=4.0; // P\nconst float ALPHA=1.0; // P\nvec3 src(vec2 p){return img(p)+(hash(floor(p*512.))-.5)*.16;}\nvoid mainImage(out vec4 fragColor,in vec2 fragCoord){\n  vec2 uv=(fragCoord-.5*iResolution.xy)/iResolution.y;bool R=uv.x>0.;vec2 q=vec2(uv.x+(R?-.25:.25),uv.y);\n  vec3 col;\n  if(!R) col=src(q);\n  else{\n    float px=1./512.,E=0.,F=0.,G=0.;\n    for(int j=-1;j<=1;j++)for(int i=-1;i<=1;i++){vec2 o=q+vec2(float(i),float(j))*4.*px;\n      float gx=lum(img(o+vec2(2.*px,0.)))-lum(img(o-vec2(2.*px,0.))),gy=lum(img(o+vec2(0.,2.*px)))-lum(img(o-vec2(0.,2.*px)));\n      E+=gx*gx;F+=gx*gy;G+=gy*gy;}\n    float th=.5*atan(2.*F,E-G),r=sqrt((E-G)*(E-G)+4.*F*F),A=r/(E+G+1e-6);\n    vec2 g=vec2(cos(th),sin(th)),f=vec2(-g.y,g.x);\n    float a=RAD*(ALPHA+A)/ALPHA,b=RAD*ALPHA/(ALPHA+A);\n    vec3 m[8],s[8];float w[8];\n    for(int k=0;k<8;k++){m[k]=vec3(0.);s[k]=vec3(0.);w[k]=0.;}\n    for(int j=-4;j<=4;j++)for(int i=-4;i<=4;i++){\n      vec2 u=vec2(float(i),float(j))/4.;float l2=dot(u,u);if(l2>1.)continue;\n      vec3 c=src(q+(u.x*a*f+u.y*b*g)*px);float wt=exp(-2.5*l2);\n      int k=int(clamp(floor((atan(u.y,u.x)/6.2831853+.5)*8.),0.,7.));\n      m[k]+=c*wt;s[k]+=c*c*wt;w[k]+=wt;}\n    vec3 acc=vec3(0.);float ws=0.;\n    for(int k=0;k<8;k++){if(w[k]<1e-4)continue;vec3 mu=m[k]/w[k];vec3 v=max(s[k]/w[k]-mu*mu,0.);\n      float wk=1./(1.+pow(20.*sqrt(v.x+v.y+v.z),QEXP));acc+=mu*wk;ws+=wk;}\n    col=acc/ws;\n  }\n  if(abs(uv.x)<.0015)col=vec3(1.);fragColor=vec4(clamp(col,0.,1.),1.);\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": "anisotropic-kuwahara",
     "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.478,
      "std": 0.2311,
      "unique_colors": 1208
     },
     "image": "/specimens/anisotropic-kuwahara-specimen.webp",
     "reason": null
    }
   }
  }
 ],
 "related": [
  "kuwahara-filter",
  "painterly-curved-brush-strokes",
  "watercolor-rendering-curtis"
 ],
 "extends": [
  "kuwahara-filter"
 ],
 "supersedes": [],
 "combines_with": [
  {
   "id": "screen-space-edge-outline",
   "why": "Painterly colour regions from the filter, lines from depth/normal 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/anisotropic-kuwahara.json"
 },
 "solves": [
  "want an oil painting look from a rendered frame",
  "blocky artifacts in painterly image filter",
  "stylize a scene so strokes follow edges and shapes",
  "photo abstraction that keeps edges crisp but smooths regions"
 ],
 "authority": "Kyprianidis et al., 2009",
 "url": "https://texelatlas.vercel.app/t/anisotropic-kuwahara/",
 "execution_fidelity": "faithful-pass",
 "fidelity_label": "Faithful Pass",
 "benchmark_eligible": true,
 "gpu_weight": {
  "weight_x": 171.01,
  "tier": "extreme",
  "p50_ms": 5.6263,
  "p95_ms": 5.7956,
  "baseline_p50_ms": 0.0329,
  "gpu": "Tesla T4/PCIe/SSE2",
  "resolution": "1920x1080",
  "method": "opengl-timer-query",
  "frames": 40,
  "preset_id": "anisotropic-kuwahara-specimen",
  "execution_fidelity": "faithful-pass",
  "fidelity_label": "Faithful Pass",
  "benchmark_eligible": true,
  "generated_at": "2026-11-30T21:07:47Z",
  "l4": {
   "weight_x": 113.45,
   "tier": "extreme",
   "p50_ms": 1.8038,
   "p95_ms": 1.825,
   "speedup_x": 3.12,
   "gpu": "NVIDIA L4/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0159
  },
  "a100": {
   "weight_x": 56.08,
   "tier": "heavy",
   "p50_ms": 1.6151,
   "p95_ms": 1.625,
   "speedup_x": 3.48,
   "gpu": "NVIDIA A100-SXM4-40GB/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0288
  }
 }
}