Finding a 2d block with highest average inside a 2d window

2 ビュー (過去 30 日間)
MSP
MSP 2018 年 3 月 1 日
コメント済み: Walter Roberson 2018 年 3 月 2 日
Consider a matrix A(52,34) How to find out which 2d block size(3,3) has the highest average in it

採用された回答

Walter Roberson
Walter Roberson 2018 年 3 月 1 日
[~, idx] = max(conv2(A, ones(3,3),'same'))
[r, c] = ind2sub(size(A), idx);
r and c is now the index of the center of the block that had the highest average.
  2 件のコメント
MSP
MSP 2018 年 3 月 2 日
編集済み: MSP 2018 年 3 月 2 日
r and c is supposed to be single values ,isnt it.If I run with A=magic(7) then it does'nt return single values.
Walter Roberson
Walter Roberson 2018 年 3 月 2 日
[~, idx] = max( reshape(conv2(A, ones(3,3),'same'), [], 1) );
[r, c] = ind2sub(size(A), idx);

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeComputer Vision with Simulink についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by