smoothdata2
Smooths a matrix in two dimensions.
Category: Data Import and Analysis > Preprocessing Data
Syntax
B = smoothdata2(A)
Smooths with a default method and window.
B = smoothdata2(A, method, wlen)
Uses method with a window of wlen, a scalar for a square window.
Description
This is the two-dimensional counterpart of smoothdata: each element is replaced by a statistic of its neighborhood in both directions, so rows and columns are smoothed together. With 'movmean' and a 3 by 3 window each interior point becomes the mean of its eight neighbors and itself; windows are truncated at the edges.
A median window removes salt-and-pepper type noise, while a mean window gives a blur.
Input arguments
A- Numeric matrix, such as an image or gridded measurements.
method'movmean','movmedian'or'gaussian'.wlen- Window size, scalar or
[rows cols].
Output arguments
B- Smoothed matrix of the same size as
A.
Example
Neighborhood mean
A = [1 2 3; 4 5 6; 7 8 9];
smoothdata2(A, 'movmean', 3)
Output
ans = 3×3
3.0000 3.5000 4.0000
4.5000 5.0000 5.5000
6.0000 6.5000 7.0000