Dilate an image. More...

Modules

 dilate
 The C++ interface for dilate.
 
 af_dilate
 The C interface for dilate.
 

Detailed Description

Dilate an image.

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