The C interface for dilate. More...

afError af_dilate_B (bool *d_out, unsigned in_ndims, const unsigned *in_dims, const bool *d_in, unsigned nhood_ndims, const unsigned *nhood_dims, const bool *d_nhood, unsigned batch)
 Dilate an image. More...
 
afError af_dilate_S (float *d_out, unsigned in_ndims, const unsigned *in_dims, const float *d_in, unsigned nhood_ndims, const unsigned *nhood_dims, const float *d_nhood, unsigned batch)
 Single precision, Image Dilation. More...
 
afError af_dilate_D (double *d_out, unsigned in_ndims, const unsigned *in_dims, const double *d_in, unsigned nhood_ndims, const unsigned *nhood_dims, const double *d_nhood, unsigned batch)
 Double precision, Image Dilation. More...
 

Detailed Description

The C interface for dilate.

The dilation function takes two pieces of data as inputs. The first is the input image to be morphed, and the second is the mask indicating the neighborhood around each pixel to match.

In dilation, for each pixel, the mask is centered at the pixel. If the center pixel of the mask matches the corresponding pixel on the image, then the mask is accepted. If the center pixels do not matches, then the mask is ignored and no changes are made.

Dilation supports n-channel images (ie. 3D matrices). However each tile must be 2D and will be the same for all channels. If you wish to use separate masks for channels, you can extract the channel, apply the operation and store the resulting channel back in the array.

Image dilation is useful for bluring and smoothing edges.

For further reference, see: Dilation (morphology)

// Convert [0-255] image to logical
img_in = img_in > 127;
// Dilate an image, 8-neighbor connectivity
array mask8 = constant(1,3,3);
array img_out = dilate(img_in, mask8);
// Dilate an image, 4-neighbor connectivity
const float h_mask4[] = { 0.0, 1.0, 0.0,
1.0, 1.0, 1.0,
0.0, 1.0, 0.0 };
array mask4 = array(3,3,h_mask4);
array img_out = dilate(img_in, mask4);
Original
Original
Mask (8-neighbor connectivity)
Mask (8-neighbor connectivity)
Intermediate
Intermediate
Result
Result

Function Documentation

afError af_dilate_B ( bool *  d_out,
unsigned  in_ndims,
const unsigned *  in_dims,
const bool *  d_in,
unsigned  nhood_ndims,
const unsigned *  nhood_dims,
const bool *  d_nhood,
unsigned  batch 
)

Dilate an image.

Parameters
[out]d_outThe dilated image
[in]in_ndimsNumber of dimension elements in in_dims
[in]in_dimsDimensions of d_in
[in]d_inInput image
[in]nhood_ndimsNumber of dimension elements in nhood_dims
[in]nhood_dimsDimensions of h_nhood
[in]d_nhoodneighborhood patch (device)
[in]batchNumber of input images
Note
h_nhood must be square and odd (3x3,5x5,7x7,...)Boolean, Image Dilation
afError af_dilate_S ( float *  d_out,
unsigned  in_ndims,
const unsigned *  in_dims,
const float *  d_in,
unsigned  nhood_ndims,
const unsigned *  nhood_dims,
const float *  d_nhood,
unsigned  batch 
)

Single precision, Image Dilation.

afError af_dilate_D ( double *  d_out,
unsigned  in_ndims,
const unsigned *  in_dims,
const double *  d_in,
unsigned  nhood_ndims,
const unsigned *  nhood_dims,
const double *  d_nhood,
unsigned  batch 
)

Double precision, Image Dilation.