On Wed, Nov 20, 2019 at 9:04 AM Juan Pablo Carbajal <
address@hidden> wrote:
Hi Brett,
Did you solve your problem?
It seems the definition of the minima you are looking for is
problematic, in 1D it reads
# assume M exist with length N
i = 2:(N - 1);
ismin = (M(i) < M(i + 1)) & (M(i) < M(i - 1))
# these are the location of minima
loc = find (ismin) + 1
But check this
M = [1 2 3 0 0 5 6];
gives you no minima. Is that alright?
Thank you! Actually, several days after asking here I also asked on Stack Overflow. It turns out Octave does indeed already have a function, imregionalmin, that serves this purpose in the image package. Most importantly,
imregionalmin
works for an array of arbitrary dimensions.
Also, it will find the "extended" minima of adjacent equal values. It also includes minima on the borders, but if that were undesirable, one could always just throw away the first and last entry for each index.
pkg load image
M = [1 2 3 0 0 5 6];
imregionalmin(M)
returns
ans =
1 0 0 1 1 0 0