61 unsigned int height,
double *vmax )
63 unsigned int wh = width * height;
64 short *xdist = (
short *)malloc( wh *
sizeof(
short ) );
65 short *ydist = (
short *)malloc( wh *
sizeof(
short ) );
66 double *gx = (
double *)calloc( wh,
sizeof(
double ) );
67 double *gy = (
double *)calloc( wh,
sizeof(
double ) );
68 double *outside = (
double *)calloc( wh,
sizeof(
double ) );
69 double *inside = (
double *)calloc( wh,
sizeof(
double ) );
72 computegradient( data, width, height, gx, gy );
73 edtaa3( data, gx, gy, width, height, xdist, ydist, outside );
74 for (
unsigned int i = 0; i < wh; i++ )
75 if ( outside[i] < 0.0 )
79 memset( gx, 0,
sizeof(
double ) * width * height );
80 memset( gy, 0,
sizeof(
double ) * width * height );
81 for (
unsigned int i = 0; i < wh; i++ )
82 data[i] = 1. - data[i];
83 computegradient( data, width, height, gx, gy );
84 edtaa3( data, gx, gy, width, height, xdist, ydist, inside );
85 for (
unsigned int i = 0; i < wh; i++ )
91 for (
unsigned int i = 0; i < wh; i++ ) {
92 outside[i] -= inside[i];
93 if ( *vmax < fabs( outside[i] ) )
94 *vmax = fabs( outside[i] );
97 for (
unsigned int i = 0; i < wh; i++ ) {
98 double v = outside[i];
101 else if ( v > +*vmax )
103 data[i] = ( outside[i] + *vmax ) / ( 2. * *vmax );
float * make_distance_mapbf(unsigned char *img, unsigned int width, unsigned int height, double *vmax)
Perform a Euclidean Distance Transform on the input and normalize to [0,1], with a value of 0....
double * make_distance_mapd(double *data, unsigned int width, unsigned int height, double *vmax)
Like the original: perform a Euclidean Distance Transform on the input and normalize to [0,...