#include "mex.h"
#include "mex_utils.h"
#include <stdlib.h>
#include "array.h"
#include "distances.h"
#include "imageproc.h"
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]){
char msg[2000];
const char *docstring =
"[ dt ] = distancetransform( binarymatrix );\n"
" The input array is treated as binary, i.e. if a value is >0, it is\n"
" assumed to be 1, else it is 0.\n";
if(nrhs<1){
sprintf(msg, ">> Need 1 input.\n%s\n", docstring);
mexErrMsgTxt(msg);
} else if(!is_mex_matrix(prhs[0])){
sprintf(msg, ">> First Input must be a double-precision matrix.\n%s\n", docstring);
mexErrMsgTxt(msg);
}
Array *binimg = mex_mxarray_to_array( prhs[0] );
array_typecast( binimg, INT );
Array *dt = disttransform_deadreckoning( binimg, NULL );
plhs[0]=mex_array_to_mxarray( dt );
array_free( binimg );
array_free( dt );
return;
}