This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


3-D median filtering


B = medfilt3(A)
B = medfilt3(A,[m n p])
B = medfilt3(___,padopt)



B = medfilt3(A) filters the 3-D image A with a 3-by-3-by-3 filter. By default, medfilt3 pads the image by replicating the values in a mirrored way at the borders.

B = medfilt3(A,[m n p]) performs median filtering of the 3-D image A in three dimensions. Each output voxel in B contains the median value in the m-by-n-by-p neighborhood around the corresponding voxel in A.

B = medfilt3(___,padopt) controls how medfilt3 pads the array boundaries.


collapse all

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.

hpatch1 = patch(isosurface(x,y,z,noisyV,0));
axis tight off
camlight left
lighting phong

hpatch2 = patch(isosurface(x,y,z,filteredV,0));
axis tight off
camlight left 
lighting phong

Input Arguments

collapse all

Input image, specified as a 3-D, real, nonsparse, numeric, or logical array. If the input image is an integer class, all the output values are also integers.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

Neighborhood size, specified as a three-element numeric vector, [m n p], of real positive integers. The values of m, n, and p must be odd integers.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32

Padding option, specified as one of the following values:

'symmetric'Pad array with mirror reflections of itself
'replicate'Pad array by repeating border elements
'zeros'Pad array with 0s

Data Types: char | string

Output Arguments

collapse all

Output image, returned as a 3-D array of the same class and size as the input image A.

See Also

Introduced in R2016b