matlab K近邻均值平滑滤波,使用均值滤波器进行二维矩阵平滑

smooth2a

Smooths 2D array data. Ignores NaN's.

function matrixOut = smooth2a(matrixIn,Nr,Nc)

This function smooths the data in matrixIn using a mean filter over a

rectangle of size (2*Nr+1)-by-(2*Nc+1). Basically, you end up replacing

element "i" by the mean of the rectange centered on "i". Any NaN

elements are ignored in the averaging. If element "i" is a NaN, then it

will be preserved as NaN in the output. At the edges of the matrix,

where you cannot build a full rectangle, as much of the rectangle that

fits on your matrix is used (similar to the default on Matlab's builtin

function "smooth").

"matrixIn": original matrix

"Nr": number of points used to smooth rows

"Nc": number of points to smooth columns. If not specified, Nc = Nr.

"matrixOut": smoothed version of original matrix

%%%%%%%%%

Explanation of screenshot:

The left plot is a pcolor (shading interp, axis equal) of a "jagged" 906x1024 matrix. Note that the edges have NaN values (white coloring). On the right, pcolor of output of smooth2a, with Nr = Nc = 50. NaN's are preserved, but do not affect the smoothing of adjacent elements.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值