Documentation

imregionalmin

Regional minima

Syntax

  • BW = imregionalmin(I) example
  • BW = imregionalmin(I,conn)
  • gpuarrayBW = imregionalmin(gpuarrayI,___) example

Description

example

BW = imregionalmin(I) returns the binary image BW that identifies the regional maxima in I. Regional minima are connected components of pixels with a constant intensity value, and whose external boundary pixels all have a higher value. In BW, pixels that are set to 1 identify regional minima; all other pixels are set to 0. By default, imregionalmin uses 8-connected neighborhoods for 2-D images and 26-connected neighborhoods for 3-D images. For higher dimensions, imregionalmin uses conndef(ndims(I)),'maximal').

This function support code generation (see Tips).

BW = imregionalmin(I,conn) specifies the desired connectivity.

example

gpuarrayBW = imregionalmin(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

Find Regional Minima in Simple Sample Image

Create a 10-by-10 pixel sample image that contains two regional minima.

A = 10*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

Find Regional Minima in Simple Sample Image on a GPU

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

Input Arguments

collapse all

I — Input imagenonsparse numeric array of any dimension

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

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

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

conn — Connectivity8 (default) | 4 | 6 | 18 | 26 | 3-by-3-by- ...-by-3 matrix of zeroes and ones

Connectivity, specified as a one of the scalar values in the following table. By default, imregionalmin uses 8-connected neighborhoods for 2-D images and 26-connected neighborhoods for 3-D images. For higher dimensions, imregionalmin uses conndef(numel(size(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 0s and 1s. The 1-valued elements define neighborhood locations relative to the center element of conn. Note that conn must be symmetric about 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: B = imregionalmin(A,4);

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

gpuarrayI — Input image for GPUgpuArray

Input image for GPU, specified as a gpuArray.

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

Output Arguments

collapse all

BW — Transformed imagelogical array

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

gpuarrayBW — Transformed imagegpuArray

Transformed image, returned as a gpuArray.

More About

collapse all

Tips

  • This function supports the generation of C code using MATLAB® Coder™. Note that if you choose the generic MATLAB Host Computer target platform, the function generates code that uses a precompiled, platform-specific shared library. Use of a shared library preserves performance optimizations but limits the target platforms for which code can be generated. For more information, see Understanding Code Generation with Image Processing Toolbox.

    When generating code, the optional second input argument, conn, must be a compile-time constant.

Was this topic helpful?