The C interface for regions. More...

afError af_regions_B (float *d_out, const unsigned nx, const unsigned ny, const bool *d_in, unsigned conn)
 Uniquely label connected components in a binary image. More...
 

Detailed Description

The C interface for regions.

Given a binary image (with zero representing background pixels), regions computes a floating point image where each connected component is labeled from 1 to N, the total number of components in the image.

A component is defined as one or more nonzero pixels that are connected by the specified connectivity (either 4-way or 8-way) in two dimensions. The default connectivity is 8-way.

// Make a random array
const int len = 8;
array r = randn(len, len) * 10.0f;
// Convert to a binary image with thresholding
array in = (r > 5.0f);
print(in);
// in =
// 0 0 0 0 1 0 1 0
// 0 0 0 0 0 0 1 1
// 0 1 0 1 0 0 0 0
// 0 0 1 0 1 1 0 1
// 1 1 0 0 0 1 0 1
// 0 0 0 1 0 0 0 1
// 0 0 0 0 1 0 0 1
// 0 1 0 0 0 1 0 0
// Compute the label matrix using 8-way connectivity
// 0 0 0 0 4 0 5 0
// 0 0 0 0 0 0 5 5
// 0 1 0 1 0 0 0 0
// 0 0 1 0 1 1 0 6
// 1 1 0 0 0 1 0 6
// 0 0 0 3 0 0 0 6
// 0 0 0 0 3 0 0 6
// 0 2 0 0 0 3 0 0

Function Documentation

afError af_regions_B ( float *  d_out,
const unsigned  nx,
const unsigned  ny,
const bool *  d_in,
unsigned  conn 
)

Uniquely label connected components in a binary image.

Parameters
[out]d_outlabeled image
[in]nxNumber of rows in image
[in]nyNumber of cols in image
[in]d_inbinary image
[in]connConnectivity (4 or 8)Logical image connected component labeling