Find the max value in a kernal

8 次查看(过去 30 天)
Steve Scott
Steve Scott 2018-3-8
I need to iterate over a 2d array finding the maximum value inside a given kernel. However, the kernel is custom, not square.

回答(1 个)

Roger Stafford
Roger Stafford 2018-3-8
编辑:Roger Stafford 2018-3-8
Let M be your matrix. Let R be a vector of the matrix's row subscripts of your kernel, and let C be a vector of corresponding column subscripts of the kernel. Then do:
mx = max(M(sub2ind(size(M),R,C))); % mx is maximum of M in kernel

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by