medfilt3
三维中位数滤波
说明
示例
使用中位数滤波去除三维数据中的离群值
创建一个含噪三维曲面。
[x,y,z,V] = flow(50); noisyV = V + 0.1*double(rand(size(V))>0.95) - 0.1*double(rand(size(V))<0.05);
应用中位数滤波。
filteredV = medfilt3(noisyV);
一起显示含噪曲面和滤波曲面。
subplot(1,2,1) hpatch1 = patch(isosurface(x,y,z,noisyV,0)); isonormals(x,y,z,noisyV,hpatch1) set(hpatch1,'FaceColor','red','EdgeColor','none') daspect([1,4,4]) view([-65,20]) axis tight off camlight left lighting phong subplot(1,2,2) hpatch2 = patch(isosurface(x,y,z,filteredV,0)); isonormals(x,y,z,filteredV,hpatch2) set(hpatch2,'FaceColor','red','EdgeColor','none') daspect([1,4,4]) view([-65,20]) axis tight off camlight left lighting phong
输入参数
A
— 输入图像
三维数值数组 | 三维逻辑数组
输入图像,指定为三维数值或逻辑数组。
数据类型: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| logical
[m n p]
— 邻域大小
[3 3 3]
(默认) | 三元素向量
邻域大小,指定为由正奇整数组成的三元素向量。
数据类型: single
| double
| int8
| int16
| int32
| uint8
| uint16
| uint32
padopt
— 填充选项
"symmetric"
(默认) | "zeros"
| "replicate"
填充选项,指定为下列值之一:
值 | 描述 |
---|---|
"symmetric" | 用自身的镜像翻转填充数组 |
"replicate" | 通过重复边框元素填充数组 |
"zeros" | 用 0 填充数组 |
数据类型: char
| string
扩展功能
基于线程的环境
使用 MATLAB® backgroundPool
在后台运行代码或使用 Parallel Computing Toolbox™ ThreadPool
加快代码运行速度。
此函数完全支持基于线程的环境。有关详细信息,请参阅在基于线程的环境中运行 MATLAB 函数。
版本历史记录
在 R2016b 中推出R2022b: 支持基于线程的环境
medfilt3
现在支持基于线程的环境。
R2021b: 改进了对小邻域的处理性能
medfilt3
函数在处理从 [3, 3, 3] 到 [31, 31, 31] 的邻域大小时的性能得到改进。
例如,以下代码比以前的版本快 3 倍。
function timingTestMedfilt3 load mristack; noisyV = imnoise(mristack,'salt & pepper',0.2); tic filteredV = medfilt3(noisyV); toc end
大致的执行时间是:
R2021a:0.24 秒
R2021b:0.08 秒
代码是在运行 Windows® 10 的Intel® Xeon® Gold 5220 CPU @ 2.2 GHz 测试系统上通过调用函数 timingTestMedfilt3
进行计时的。
另请参阅
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)