Create a 10-by-10 pixel sample image that contains two
regional minima.
A = 10*gpuArray.ones(10,10);
A(2:4,2:4) = 3; % minima 3 lower than surround
A(6:8,6:8) = 8 % minima 8 lower than surroundA(6:8,6:8) = 7;
A =
10 10 10 10 10 10 10 10 10 10
10 3 3 3 10 10 10 10 10 10
10 3 3 3 10 10 10 10 10 10
10 3 3 3 10 10 10 10 10 10
10 10 10 10 10 10 10 10 10 10
10 10 10 10 10 8 8 8 10 10
10 10 10 10 10 8 8 8 10 10
10 10 10 10 10 8 8 8 10 10
10 10 10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10 10 10
Pass the sample image A to imregionalmin.
The function returns a binary image, the same size as A,
in which pixels with the value 1 represent the
regional minima in A. imregionalmin sets
all other pixels in to 0.
regmin = imregionalmin(A)
regmin =
0 0 0 0 0 0 0 0 0 0
0 1 1 1 0 0 0 0 0 0
0 1 1 1 0 0 0 0 0 0
0 1 1 1 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 1 1 1 0 0
0 0 0 0 0 1 1 1 0 0
0 0 0 0 0 1 1 1 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0