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 CenterFile Exchange에서 Computer Vision with Simulink에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by