You are here : matlabImage Processingimregionalmax

imregionalmax() - Image Processing

```BW = imregionalmax(I) returns
the binary image BW that identifies the regional
maxima in I. Regional maxima are connected components
of pixels with a constant intensity value, t, whose
external boundary pixels all have a value less than t.
In BW, pixels that are set to 1 identify
regional maxima; all other pixels are set to 0.BW = imregionalmax(I,conn) computes
the regional maxima, where conn specifies the connectivity.
By default, imregionalmax uses 8-connected neighborhoods
for 2-D images and 26-connected neighborhoods for 3-D images.gpuarrayBW = imregionalmax(gpuarrayI,___) performs
the operation on a GPU. The input image must be a gpuArray.
The function returns a gpuArray. This syntax requires Parallel Computing Toolboxâ„˘.Code Generation support:
Yes.MATLAB Function Block support:
Yes.```

Syntax

`BW = imregionalmax(I) exampleBW = imregionalmax(I,conn)gpuarrayBW = imregionalmax(gpuarrayI,___)`

Example

```Find Regional Maxima in Simple Sample ImageOpen This Example
Create a simple sample image with several regional maxima.A = 10*ones(10,10);
A(2:4,2:4) = 22;
A(6:8,6:8) = 33;
A(2,7) = 44;
A(3,8) = 45;
A(4,9) = 44

A =

10    10    10    10    10    10    10    10    10    10
10    22    22    22    10    10    44    10    10    10
10    22    22    22    10    10    10    45    10    10
10    22    22    22    10    10    10    10    44    10
10    10    10    10    10    10    10    10    10    10
10    10    10    10    10    33    33    33    10    10
10    10    10    10    10    33    33    33    10    10
10    10    10    10    10    33    33    33    10    10
10    10    10    10    10    10    10    10    10    10
10    10    10    10    10    10    10    10    10    10

Find the regional maxima. Note that the result includes the regional maxima at (3,8).regmax = imregionalmax(A)

regmax =

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     1     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

Find Regional Maxima in Simple Sample Image on a GPUCreate a 10-by-10 pixel sample image that contains two
regional maxima.A = 10*gpuArray.ones(10,10);
A(2:4,2:4) = 22;    % maxima 12 higher than surrounding pixels
A(6:8,6:8) = 33;    % maxima 23 higher than surrounding pixels
A(2,7) = 44;
A(3,8) = 45;     % maxima 1 higher than surrounding pixels
A(4,9) = 44
A =

10    10    10    10    10    10    10    10    10    10
10    22    22    22    10    10    44    10    10    10
10    22    22    22    10    10    10    45    10    10
10    22    22    22    10    10    10    10    44    10
10    10    10    10    10    10    10    10    10    10
10    10    10    10    10    33    33    33    10    10
10    10    10    10    10    33    33    33    10    10
10    10    10    10    10    33    33    33    10    10
10    10    10    10    10    10    10    10    10    10
10    10    10    10    10    10    10    10    10    10Pass the sample image A to imregionalmax.
The function returns a binary image, the same size as A,
in which pixels with the value 1 represent the
regional maxima in A. imregionalmax sets
all other pixels in to 0.regmax = imregionalmax(A)regmax =

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     1     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```