sum the matrix 3x3 and looping
1 回表示 (過去 30 日間)
古いコメントを表示
how to calculate the total of overlap region 3x3 of a matrix and include loop function as it continue to calculate row by row and column by column.
2 件のコメント
the cyclist
2014 年 2 月 28 日
編集済み: the cyclist
2014 年 2 月 28 日
This is not even close to detailed enough to help you. For starters, what does "overlap region" mean?
Please remember, we only know what you tell us about your problem.
Here is a nice guide to asking good questions here: http://www.mathworks.com/matlabcentral/answers/6200-tutorial-how-to-ask-a-question-on-answers-and-get-a-fast-answer
採用された回答
Image Analyst
2014 年 3 月 1 日
That can be done very simply with imfilter() or conv2():
outputArray = conv2(double(inputArray), ones(3), 'same');
Every element (pixel) in the output array (image) will be the sum of input elements (pixels) in the sliding window.
7 件のコメント
Image Analyst
2014 年 3 月 2 日
編集済み: Image Analyst
2014 年 3 月 2 日
x = [1 2 3 4;5 6 7 8;9 10 11 12;13 14 15 16]
theSums = conv2(x, ones(3), 'valid')
Result:
theSums =
54 63
90 99
As you can see, you forgot one sum. Please mark the answer as Accepted if we're done here. Thanks.
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!