Documentation

conndef

Create connectivity array

Syntax

conn = conndef(num_dims,type)

Description

conn = conndef(num_dims,type) returns the connectivity array defined by type for num_dims dimensions. type can have either of the values listed in this table.

Value

Description

'minimal'

Defines a neighborhood whose neighbors are touching the central element on an (N-1)-dimensional surface, for the N-dimensional case.

'maximal'

Defines a neighborhood including neighbors that touch the central element in any way; it is ones(repmat(3,1,NUM_DIMS)).

Several Image Processing Toolbox™ functions use conndef to create the default connectivity input argument.

This function supports code generation (see Tips).

Examples

The minimal connectivity array for two dimensions includes the neighbors touching the central element along a line.

conn1 = conndef(2,'minimal')

conn1 =
     0     1     0
     1     1     1
     0     1     0

The minimal connectivity array for three dimensions includes all the neighbors touching the central element along a face.

conndef(3,'minimal')

ans(:,:,1) =
     0     0     0
     0     1     0
     0     0     0

ans(:,:,2) =
     0     1     0
     1     1     1
     0     1     0

ans(:,:,3) =
     0     0     0
     0     1     0
     0     0     0

The maximal connectivity array for two dimensions includes all the neighbors touching the central element in any way.

conn2 = conndef(2,'maximal')

conn2 =
     1     1     1
     1     1     1
     1     1     1

More About

collapse all

Tips

  • This function supports the generation of C code using MATLAB® Coder™. For more information, see Code Generation for Image Processing.

    When generating code, the dir, fstep, and conn arguments must be compile-time constants.

Was this topic helpful?