medfilt3
3-D median filtering
Description
Examples
Use Median Filtering to Remove Outliers in 3-D Data
Create a noisy 3-D surface.
[x,y,z,V] = flow(50); noisyV = V + 0.1*double(rand(size(V))>0.95) - 0.1*double(rand(size(V))<0.05);
Apply median filtering.
filteredV = medfilt3(noisyV);
Display the noisy and filtered surfaces together.
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
Input Arguments
A
— Input image
3-D numeric array | 3-D logical array
Input image, specified as a 3-D numeric or logical array.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| logical
[m n p]
— Neighborhood size
[3 3 3]
(default) | 3-element vector
Neighborhood size, specified as a 3-element vector of positive odd integers.
Data Types: single
| double
| int8
| int16
| int32
| uint8
| uint16
| uint32
padopt
— Padding option
"symmetric"
(default) | "zeros"
| "replicate"
Padding option, specified as one of the following values:
Value | Description |
---|---|
"symmetric" | Pad array with mirror reflections of itself |
"replicate" | Pad array by repeating border elements |
"zeros" | Pad array with 0 s |
Data Types: char
| string
Output Arguments
B
— Output image
3-D numeric array
Output image, returned as a 3-D numeric array of the same class and size as the input image
A
.
Extended Capabilities
Thread-Based Environment
Run code in the background using MATLAB® backgroundPool
or accelerate code with Parallel Computing Toolbox™ ThreadPool
.
This function fully supports thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment.
Version History
Introduced in R2016bR2022b: Support for thread-based environments
medfilt3
now supports thread-based
environments.
R2021b: Improved performance for small neighborhood sizes
The medfilt3
function shows improved performance
for neighborhood sizes from [3, 3, 3] up to [31, 31, 31].
For example, this code is about 3x faster than in the previous release.
function timingTestMedfilt3 load mristack; noisyV = imnoise(mristack,'salt & pepper',0.2); tic filteredV = medfilt3(noisyV); toc end
The approximate execution times are:
R2021a: 0.24 s
R2021b: 0.08 s
The code was timed on a Windows® 10, Intel®
Xeon® Gold 5220 CPU @ 2.2 GHz test system by calling the
function timingTestMedfilt3
.
See Also
Ouvrir l'exemple
Vous possédez une version modifiée de cet exemple. Souhaitez-vous ouvrir cet exemple avec vos modifications ?
Commande MATLAB
Vous avez cliqué sur un lien qui correspond à cette commande MATLAB :
Pour exécuter la commande, saisissez-la dans la fenêtre de commande de MATLAB. Les navigateurs web ne supportent pas les commandes 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)