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

 Respuesta aceptada

[~, 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 comentarios

MSP
MSP el 2 de Mzo. de 2018
Editada: MSP el 2 de Mzo. de 2018
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.
[~, idx] = max( reshape(conv2(A, ones(3,3),'same'), [], 1) );
[r, c] = ind2sub(size(A), idx);

Iniciar sesión para comentar.

Más respuestas (0)

Preguntada:

MSP
el 1 de Mzo. de 2018

Comentada:

el 2 de Mzo. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by