主要内容

medfilt3

R2026b

三维中位数滤波

描述

B = medfilt3(A) 使用 3×3×3 滤波器对三维图像 A 进行中位数滤波。默认情况下,medfilt3 通过在边界处以镜像方式复制值来填充图像。

示例

B = medfilt3(A,[m n p]) 对三维图像 A 执行三维中位数滤波。B 中的每个输出体素包含 A 中对应体素周围 m×n×p 邻域的中位数值。

B = medfilt3(___,padopt) 控制 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);
filteredVnopad = medfilt3(noisyV,[3 3 3],"zeros");

显示含噪曲面和滤波曲面。观察滤波后的曲面比含噪曲面噪声更少。还要注意观察,当您指定零填充时,滤波曲面的边缘比默认对称填充更粗糙。

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]) 
title("Noisy Surface")
axis tight off
camlight left
lighting gouraud

Figure contains an axes object. The hidden axes object with title Noisy Surface contains an object of type patch.

subplot(1,2,1)
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])
title("Symmetric Padding")
axis tight off
camlight left 
lighting gouraud

subplot(1,2,2)
hpatch3 = patch(isosurface(x,y,z,filteredVnopad,0));
isonormals(x,y,z,filteredVnopad,hpatch3)
set(hpatch3,FaceColor="red",EdgeColor="none")
daspect([1,4,4])
view([-65,20])
title("Zero Padding")
axis tight off
camlight left 
lighting gouraud

Figure contains 2 axes objects. Hidden axes object 1 with title Symmetric Padding contains an object of type patch. Hidden axes object 2 with title Zero Padding contains an object of type patch.

输入参数

全部折叠

输入图像,指定为三维数值或逻辑数组。

数据类型: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

邻域大小,指定为由正奇整数组成的三元素向量。

数据类型: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32

填充选项,指定为下列值之一:

值描述示例
"symmetric"用自身的镜像翻转填充数组

[314159265]→[5115995133144113314415115995622655662265565115995]

"replicate"通过重复边框元素填充数组

[314159265]→[3331444333144433314441115999222655522265552226555]

"zeros"用值 0 填充数组

[314159265]→[0000000000000000314000015900002650000000000000000]

数据类型: char | string

输出参量

全部折叠

输出图像,以与输入图像 A 大小和数据类型相同的数值三维数组形式返回。

扩展功能

全部展开

版本历史记录

在 R2016b 中推出

全部展开