KuwaharaFilter[data,r]
computes for each element p in data the variance of the values in the four (r+1)×(r+1) squares that have p as a corner, and replaces p with the mean of the values of the square with least variance.
KuwaharaFilter
KuwaharaFilter[data,r]
computes for each element p in data the variance of the values in the four (r+1)×(r+1) squares that have p as a corner, and replaces p with the mean of the values of the square with least variance.
Details
- KuwaharaFilter is a nonlinear local filter typically used for edge-preserving smoothing.
- The data can be any of the following:
-
list arbitrary-rank numerical array tseries temporal data such as TimeSeries, TemporalData, … image arbitrary Image or Image3D object audio an Audio object video a Video object - For multi-channel data, KuwaharaFilter computes the sum of the variances in each channel.
- KuwaharaFilter[data,{r1,r2,…}] uses
blocks. - KuwaharaFilter assumes the index coordinate system for lists and images.
- At the data boundaries, KuwaharaFilter uses smaller neighborhoods.
Examples
open all close allBasic Examples (2)
Kuwahara filtering of an image:
KuwaharaFilter[[image], 3]Kuwahara filtering of a signal:
data = TemporalData[TimeSeries, {{{-0.1807621426976858, 0.1413032974253584, 0.14787020336891699,
-0.18283488261794334, -0.03389990261702913, -0.01981257214348542, 0.030642813601194474,
0.16788346166120727, -0.12656460929996266, 0.097159702207544 ... 32831686447162, 0.08706753196133699, -0.054206874420813844,
0.1733508109246914, 0.033414574408857645}}, {{0, 100, 1}}, 1, {"Continuous", 1},
{"Discrete", 1}, 1, {ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}}}, False, 12.];
ListLinePlot[{data, KuwaharaFilter[data, 10]}]Scope (8)
Data (6)
KuwaharaFilter[{1, 2, 1, -1, 0, 2}, 1]Filter a TimeSeries:
ts = TemporalData[TimeSeries, {{{0., -0.054108337548928784, 0.1280211704499059, 0.28162021808461324,
-0.2057320325139802, -0.4871901025739722, -0.7154387408784426, -0.7399660905024047,
-0.6981022018441507, -0.7178077145466483, -0.8034462541874 ... 7894984276149, 1.8851123992920942, 1.8341759268762767, 2.0335844117979263}},
{{0., 10., 0.1}}, 1, {"Continuous", 1}, {"Continuous", 1}, 1,
{ValueDimensions -> 1, ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}}}, False,
10.];
filtered = KuwaharaFilter[ts, 5]ListLinePlot[{ts, filtered}, PlotLegends -> {"original data", "filtered"}]Filter an Audio signal:
a = Import["ExampleData/rule30.wav"];
b = KuwaharaFilter[a, 40]AudioPlot[{a, b}]Smoothing the image, while preserving the edges:
KuwaharaFilter[[image], 3]KuwaharaFilter[Video["ExampleData/fish.mp4"], 3]Kuwahara filter applied to a 3D image:
KuwaharaFilter[[image], 3]Parameters (2)
Kuwahara filtering just in the vertical direction:
KuwaharaFilter[[image], {10, 0}]KuwaharaFilter[[image], {0, 10}]Kuwahara filtering of a 3D image in the vertical direction only:
KuwaharaFilter[[image], {4, 0, 0}]Filtering of the horizontal planes only:
KuwaharaFilter[[image], {0, 4, 4}]Applications (4)
Use Kuwahara filtering as a preprocessing step for image segmentation:
ClusteringComponents[KuwaharaFilter[[image], 2], 6]// ColorizeKuwaharaFilter[[image], 2]Use a Kuwahara filter to remove smaller stars from an astronomical image:
KuwaharaFilter[[image], 2]Use a Kuwahara filter to create an artistic oil painting effect:
KuwaharaFilter[[image], 4]Properties & Relations (2)
Neat Examples (1)
Repeatedly apply KuwaharaFilter to an image:
FixedPoint[KuwaharaFilter[#, 5]&, [image], 150]History
Introduced in 2010 (8.0) | Updated in 2012 (9.0) ▪ 2014 (10.0) ▪ 2016 (11.0) ▪ 2025 (14.3)
Text
Wolfram Research (2010), KuwaharaFilter, Wolfram Language function, https://reference.wolfram.com/language/ref/KuwaharaFilter.html (updated 2025).
CMS
Wolfram Language. 2010. "KuwaharaFilter." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2025. https://reference.wolfram.com/language/ref/KuwaharaFilter.html.
APA
Wolfram Language. (2010). KuwaharaFilter. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/KuwaharaFilter.html
BibTeX
@misc{reference.wolfram_2026_kuwaharafilter, author="Wolfram Research", title="{KuwaharaFilter}", year="2025", howpublished="\url{https://reference.wolfram.com/language/ref/KuwaharaFilter.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_kuwaharafilter, organization={Wolfram Research}, title={KuwaharaFilter}, year={2025}, url={https://reference.wolfram.com/language/ref/KuwaharaFilter.html}, note=[Accessed: 12-June-2026]}