# Documentation

### This is machine translation

Translated by
Mouseover text to see original. Click the button below to return to the English verison of the page.

# imregionalmax

Regional maxima

## Syntax

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

## Description

example

````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™.```

## Examples

collapse all

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 = 10x10 logical array 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 ```

Create 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 10```

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

## Input Arguments

collapse all

Input array, specified as a nonsparse numeric array of any dimension.

Example: `I = imread('glass.png'); BW = imregionalmax(I);`

Data Types: `single` | `double` | `int8` | `int16` | `int32` | `int64` | `uint8` | `uint16` | `uint32` | `uint64` | `logical`

Connectivity, specified as a one of the scalar values in the following table. By default, `imregionalmax` uses 8-connected neighborhoods for 2-D images and 26-connected neighborhoods for 3-D images. For higher dimensions, `imregionalmax` uses `conndef(ndims(I),'maximal')`. Connectivity can be defined in a more general way for any dimension by using for `conn` a 3-by-3-by- ...-by-3 matrix of `0`s and `1`s. The `1`-valued elements define neighborhood locations relative to the center element of `conn`. Note that `conn` must be symmetric around its center element.

Value

Meaning

Two-dimensional connectivities

4

4-connected neighborhood

8

8-connected neighborhood

Three-dimensional connectivities

6

6-connected neighborhood

18

18-connected neighborhood

26

26-connected neighborhood

Example: `regmax = imregionalmax(A,4);`

Data Types: `single` | `double` | `int8` | `int16` | `int32` | `int64` | `uint8` | `uint16` | `uint32` | `uint64`

Input image for GPU, specified as a gpuArray.

Example: ```gpuarrayI = gpuArray(imread('cameraman.tif')); gpuarrayBW = imregionalmax(gpuarrayI);```

## Output Arguments

collapse all

Transformed image, returned as a logical array the same size as `I`.

Transformed image, returned as a gpuArray.