distancetransformcv

Calculates the distance to the closest zero pixel and normalizes the output image.

Syntax

R = distancetransformcv(handle, dtype, msize...)

R = distancetransformcv(handle, dtype, msize, type)

Inputs

handle
Handle of a single channel grayscale image.
Type: integer
dtype
Distance type. Valid values are:
-1
cv::DIST_USER
1
cv::DIST_L1
2
cv::DIST_L2
3
cv::DIST_C
4
cv::DIST_L12
5
cv::DIST_FAIR
6
cv::WELSCH
7
cv::DIST_HUBER
Type: integer
msize
Size of the mask. Valid values are:
3
cv::DIST_MASK_3.
5
cv::DIST_MASK_5
0
cv::DIST_MASK_PRECISE
Type: integer
type
Optional parameter specifying the output type. Default value is 5. Valid values are:
5
CV_32F: Default value.
0
CV_8U: Output can be this type only if dtype has a value of 1 (cv::DIST_L1)
Type: integer

Outputs

R
Handle of the output image.
Type: integer

Example

Apply distance transformation on an image:

handle = imreadcv('and1.jpeg', 0);
dtype = 1;
msize = 3;
type = 5;
R = distancetransformcv(handle, dtype, msize, type);