smooth3

Smooths a 3-D data array with a box or Gaussian filter.

Category: Graphics > 2-D and 3-D Plots

Syntax

W = smooth3(V)

Smooths V with a 3-by-3-by-3 box filter.

W = smooth3(V, 'gaussian')

Uses a Gaussian kernel instead.

W = smooth3(V, filter, sz, sd)

Sets the filter size sz and the Gaussian standard deviation sd.

Description

Each output value is a weighted average of the neighborhood around the corresponding input value. Smoothing is typically applied to noisy volume data before extracting an isosurface with isosurface, so the surface comes out less jagged.

Input arguments

V
3-D array of values.
filter
'box' (default) or 'gaussian'.
sz
Size of the kernel, as a scalar or a three-element vector. The default is 3.
sd
Standard deviation of the Gaussian kernel.

Output arguments

W
Smoothed array, of the same size as V.

Example

Smoothing random data

rng(1);
V = rand(5, 5, 5);
W = smooth3(V);
disp(size(W))
disp(std(W(:)) < std(V(:)))
Output
     5     5     5
   1

See also

isosurface convn smoothdata