MATLAB Answers

0

Find the max value in a kernal

Asked by Steve Scott on 8 Mar 2018
Latest activity Edited by Roger Stafford on 8 Mar 2018
I need to iterate over a 2d array finding the maximum value inside a given kernel. However, the kernel is custom, not square.

  0 Comments

Sign in to comment.

1 Answer

Answer by Roger Stafford on 8 Mar 2018
Edited by Roger Stafford on 8 Mar 2018

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

  0 Comments

Sign in to comment.