フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

question about fun defining

1 回表示 (過去 30 日間)
Andrea
Andrea 2012 年 7 月 17 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
I want to create this fun as below:
R=rand(100);
diff=rand(25);
sum_r1=rand(25);;
fun =@(x) x(:)+x(:).*diff(:)./sum_r1(:);
R_im=nlfilter(R,[2 2],fun);
In fact, I want to add the amount of (diff/sum_r1).x(:) in each neighborhood of 2 by 2 to x(:); I mean I have 1 diff and 1 sum_r1 for every 2 by 2 neighborhood of R. But it gives me an error!
Can anybody please help me?
  4 件のコメント
Walter Roberson
Walter Roberson 2012 年 7 月 17 日
編集済み: Walter Roberson 2012 年 7 月 17 日
In your code, you do not have 1 diff and 1 sum_r1 for each 2 x 2 neighborhood in R: in your code, you have 1 diff and 1 sum_r1 total
Also, watch out: there are 2500 non-overlapping 2 x 2 neighborhoods in a 100 x 100 matrix, not merely 25. And nlfilter() does sliding windows, not non-overlapping windows.
Perhaps you should consider using blkproc() instead of nlfilter()
Andrea
Andrea 2012 年 7 月 17 日
Thanks. I will give it a try.

回答 (0 件)

この質問は閉じられています。

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by