DIPlib Documentation - ©1995-2015 Quantitative Imaging Group, Delft University of Technology.

# ImageChainCode

Extracts all chain codes from a labeled image

## SYNOPSIS

`#include "dip_chaincode.h"`

dip_Error dip_ImageChainCode ( objectIm, connectivity, objectID, chaincodearray, resources )

## DATA TYPES

integer

## FUNCTION

Extracts the chain codes for the objects in `objectIm` (only 2D images supported) that are listed in `objectID`, assuming that each object is compact (i.e. it returns the chain code for only one border for each label ID in `objectID`). Chain codes are constructed according to `connectivity`, which can only be 1 or 2 (see The connectivity parameter). The output structure `chaincodearray` is allocated by this function and registered in `resources`.

The `dip_ChainCodeArray` structure, like all arrays in DIPlib, contains a `size` and an `array` element. Each element is of type `dip_ChainCode`, and accessed by `chaincodearray->array[ii]`, where `ii` is between `0` and `chaincodearray->size-1`. Data in the `dip_ChainCode` structures can only be accessed through the corresponding access functions, see `ChainCodeNew`.

## ARGUMENTS

Data type | Name | Description
`dip_Image` | `objectIm` | Labeled input image
`dip_int` | `connectivity` | Pixel connectivity of the objects
`dip_IntegerArray` | `objectID` | Array containing object label values
`dip_ChainCodeArray *` | `chaincodearray` | Output chain codes
`dip_Resources` | `resources` | Resources tracking structure. See `ResourcesNew`

## SEE ALSO

`ChainCodeNew`, `ChainCodeFree`, `ChainCodeArrayNew`, `ChainCodeArrayFree`, `ChainCodeGetSize`, `ChainCodeGetChains`, `ChainCodeGetStart`, `ChainCodeGetLabel`, `ChainCodeGetConnectivity`, `ChainCodeGetLength`, `ChainCodeGetLongestRun`, `ChainCodeGetFeret`