Main Content

conndef

Create connectivity array

Description

example

conn = conndef(num_dims,type) returns the pixel connectivity array defined by type for num_dims dimensions. Several Image Processing Toolbox™ functions use conndef to create the default connectivity input argument.

Examples

collapse all

Create a 2-D connectivity array.

conn = conndef(2,'minimal')
conn = 3×3

     0     1     0
     1     1     1
     0     1     0

Create a 2-D connectivity array.

conn = conndef(2,'maximal')
conn = 3×3

     1     1     1
     1     1     1
     1     1     1

Create a 3-D connectivity array.

conndef(3,'minimal')
ans = 
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

Input Arguments

collapse all

Number of dimensions, specified as a positive integer.

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

Type of neighborhood connectivity, specified as 'minimal' or 'maximal'

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)).

Data Types: char | string

Output Arguments

collapse all

Pixel connectivity, returned as a 3-by-3-....-by-3 logical array. conn is symmetric about its center element. See Specifying Custom Connectivities for more information.

Extended Capabilities

Version History

Introduced before R2006a