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

# conndef

Create connectivity array

## Syntax

``conn = conndef(num_dims,type)``

## Description

example

````conn = conndef(num_dims,type)` returns the 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 = 0 1 0 1 1 1 0 1 0 ```

Create a 2-D connectivity array.

`conn = conndef(2,'maximal')`
```conn = 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 numeric scalar.

Example: `conn1 = conndef(2,'minimal')`

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

Type of neighborhood connectivity, specified as either `'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))`.

Example: `conn1 = conndef(2,'minimal')`

Data Types: `char`

## Output Arguments

collapse all

Connectivity matrix, returned as a 3-by-3-....-by-3 logical array.