M-point averaging filter
3 ビュー (過去 30 日間)
古いコメントを表示
I need to implement a one-dimensional M-point averaging filter for a matrix consisting of values (pixels of an image) between 0 and 1, such that each pixel value is replaced by the equal-weighted average of its (M − 1)/2 neighbors to its left, (M − 1)/2 neighbors to its right, and the pixel value itself.
For instance, for M = 3, it would be like:
y[n,m]= 1/3 (x[n,m−1] + x[n,m] + x[n,m+1])
Please help me out with this. Thank you.
2 件のコメント
Austin Thai
2021 年 4 月 17 日
編集済み: Austin Thai
2021 年 4 月 17 日
Have you checked out the movmean function? You should be able to do
y[n,:]=movmean(x(n,:),3)
Image Analyst
2021 年 4 月 17 日
採用された回答
the cyclist
2021 年 4 月 17 日
編集済み: the cyclist
2021 年 4 月 17 日
% Define some data
A = reshape(1:15,3,5);
% Take the moving average of 3 elements, across the rows.
movmean(A,3,2)
0 件のコメント
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!