CommonestFilter[data,r]
通过用范围为 r 的邻域内最常见的值替换每个值对 data 进行滤波.
CommonestFilter[data,{r1,r2,…}]
对数据中的第
维用 ri 进行滤波.
CommonestFilter
CommonestFilter[data,r]
通过用范围为 r 的邻域内最常见的值替换每个值对 data 进行滤波.
CommonestFilter[data,{r1,r2,…}]
对数据中的第
维用 ri 进行滤波.
更多信息
- CommonestFilter,亦称为众数滤波器,通过返回最常见 (commonest) 的局部值对数据进行滤波,其作用的范围取决于 r 的值.
- 应用于每个范围为 r 的邻域的函数是 Commonest.
- 如果存在多个最常见的像素并且中心像素是其中之一,则使用中心像素. 否则,用随机的最常见像素进行替换.
- data 可以为以下任意形式:
-
list 任意维度的数值数组 tseries 时态数据,如 TimeSeries、TemporalData、… image 任意 Image 或 Image3D 对象 audio Audio 对象 video Video 对象 - 对于多通道图像,CommonestFilter 用邻域中最常见的像素向量替换每个像素.
- CommonestFilter[data,{r1,r2,…}] 计算以每个样本为中心的、大小为
的区域内最常见的值. - CommonestFilter 假定列表和图像采用索引坐标系统.
- 在数据的边界处,CommonestFilter 使用较小的邻域.
范例
打开所有单元 关闭所有单元基本范例 (3)
CommonestFilter[{0, 1, -1, 1, 2, 1, 3, 3, 3, 1}, 1]对 TimeSeries 进行滤波:
ts = TemporalData[TimeSeries, {{{-1, -2, -4, -4, -6, -7, -8, -11, -13, -11, -12, -11, -11, -12, -13,
-13, -12, -11, -9, -8, -8, -7, -6, -7, -10, -11, -10, -9, -10, -9, -7, -7, -7, -8, -7, -7, -7,
-8, -7, -8, -8, -7, -7, -7, -6, -6, -6, -7, -7, ... 2, -73, -73, -73, -74,
-73, -73, -74, -75, -76, -75, -75, -74, -73, -72, -73, -75, -74, -74, -74}}, {{0, 782, 1}}, 1,
{"Continuous", 1}, {"Discrete", 1}, 1,
{ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}}}, False, 11.1];filtered = CommonestFilter[ts, 50]ListLinePlot[{ts, filtered}, PlotLegends -> {"original data", "filtered"}]CommonestFilter[[image], 3]范围 (12)
数据 (8)
CommonestFilter[ {a, b, b, c, c, c, d, d, e}, 2]CommonestFilter[(| | | | |
| - | - | - | - |
| 1 | 1 | 2 | 0 |
| 2 | 3 | 1 | 1 |
| 1 | 1 | 0 | 0 |
| 0 | 1 | 2 | 3 |), 1]//MatrixFormdata = {Quantity[2, "Meters"], Quantity[0, "Meters"], Quantity[0, "Meters"], Quantity[3, "Meters"], Quantity[0, "Meters"], Quantity[1, "Meters"], Quantity[3, "Meters"], Quantity[1, "Meters"], Quantity[1, "Meters"], Quantity[3, "Meters"], Quantity[3, "Meters"], Quantity[1, "Meters"]};filtered = CommonestFilter[data, 1]对 EventSeries 进行众数滤波:
es = TemporalData[EventSeries, {{{8, 3, 1, 4, 10, 9, 4, 8, 5, 3, 5, 6, 1, 8, 3, 3, 2, 5, 0, 6, 4, 4, 3,
10, 0, 1, 1, 10, 3, 5, 2, 1, 8, 8, 2, 10, 9, 5, 4, 9, 8, 5, 1, 2, 8, 10, 0, 5, 8, 10, 0, 4, 4,
5, 8, 0, 8, 2, 3, 5, 9, 6, 5, 6, 10, 1, 8, 4 ... , 4, 0, 0, 7, 4, 6, 6, 6, 7,
7, 1, 9, 2, 3, 9, 10, 6, 2, 9, 7, 10, 5, 9, 7, 7, 9, 6, 7, 8, 6, 7, 8, 0, 2, 5, 5, 8, 7, 0, 9,
2, 2, 4, 5}}, {{0, 149, 1}}, 1, {"Discrete", 1}, {"Discrete", 1}, 1,
{ResamplingMethod -> None}}, False, 10.1];filtered = CommonestFilter[es, 10]ListPlot[{es, filtered}, PlotLegends -> {"original data", "filtered"}, Filling -> Axis]对 Audio 信号进行众数滤波:
a = Import["ExampleData/rule30.wav"];b = CommonestFilter[a, 35]AudioPlot[{a, b}]CommonestFilter[[image], 5]CommonestFilter[Video["ExampleData/fish.mp4"], 3]CommonestFilter[ExampleData[{"TestImage3D", "CTengine"}], 2]参数 (4)
CommonestFilter[[image], 3]Table[Labeled[CommonestFilter[[image], r], Text["*r* = " <> ToString@r]], {r, {1, 3, 6}}]CommonestFilter[[image], {10, 0}]CommonestFilter[[image], {0, 10}]CommonestFilter[[image], {15, 0, 0}]CommonestFilter[[image], {0, 5, 5}]应用 (2)
属性和关系 (1)
对于二值图像,众数滤波器给出与 MedianFilter 同样的结果:
i = [image];
CommonestFilter[i, 3] === MedianFilter[i, 3]可能存在的问题 (1)
技术笔记
-
▪
- 图像处理
文本
Wolfram Research (2008),CommonestFilter,Wolfram 语言函数,https://reference.wolfram.com/language/ref/CommonestFilter.html (更新于 2025 年).
CMS
Wolfram 语言. 2008. "CommonestFilter." Wolfram 语言与系统参考资料中心. Wolfram Research. 最新版本 2025. https://reference.wolfram.com/language/ref/CommonestFilter.html.
APA
Wolfram 语言. (2008). CommonestFilter. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/CommonestFilter.html 年
BibTeX
@misc{reference.wolfram_2026_commonestfilter, author="Wolfram Research", title="{CommonestFilter}", year="2025", howpublished="\url{https://reference.wolfram.com/language/ref/CommonestFilter.html}", note=[Accessed: 16-September-2026]}
BibLaTeX
@online{reference.wolfram_2026_commonestfilter, organization={Wolfram Research}, title={CommonestFilter}, year={2025}, url={https://reference.wolfram.com/language/ref/CommonestFilter.html}, note=[Accessed: 16-September-2026]}