Implement the following formula
2 ビュー (過去 30 日間)
古いコメントを表示
How can I implement the following formula? Please write the code for it. Thanks.
y[n,m]= 1/3( x[n,m−1] + x[n,m] + x[n,m+1] )
0 件のコメント
採用された回答
Image Analyst
2021 年 4 月 17 日
kernel = [1,1,1]/3;
y = conv(x, kernel, 'same'); % Convolution does that. All rows, one row at a time.
or
y(n, :) = movmean(x(n, :), 3); % For the nth row only.
2 件のコメント
Image Analyst
2021 年 4 月 17 日
Do you want to blur all the rows with a 1-by-3 array? If so you can use conv2 or imfilter
kernel = [1,1,1]/3;
y = conv(grayImage, kernel, 'same'); % Convolution does that. All rows, one row at a time.
y = imfilter(grayImage, kernel)
Or do you want to blur just the nth row and leave the other rows unchanged?
その他の回答 (1 件)
Alan Stevens
2021 年 4 月 17 日
Change the square brackets, [ ], to curved brackets, ( ). Put a multiply sign, *, after the 3.
2 件のコメント
Image Analyst
2021 年 4 月 17 日
OK, if you don't know how to do a for loop, then you have not even taken the most basic training on MATLAB. So follow this link and learn how to do simple things like for loops, if statements, assignments, referencing elements in an array, etc.:
参考
カテゴリ
Help Center および File Exchange で Image Data Workflows についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!