• API Main Page
  • Documentation
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

matlab/mex/distancetransform.c

Go to the documentation of this file.
00001 
00030 #include "mex.h"
00031 #include "mex_utils.h"
00032 
00033 #include <stdlib.h>
00034 #include "array.h"
00035 #include "distances.h"
00036 #include "imageproc.h"
00037 
00038 
00039 void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]){ 
00040   char msg[2000];
00041   const char *docstring = 
00042      "[ dt ] = distancetransform( binarymatrix );\n"
00043      " The input array is treated as binary, i.e. if a value is >0, it is\n"
00044      " assumed to be 1, else it is 0.\n";
00045   
00046   /* check proper input and output */
00047   if(nrhs<1){
00048     sprintf(msg, ">> Need 1 input.\n%s\n", docstring);
00049     mexErrMsgTxt(msg);
00050   } else if(!is_mex_matrix(prhs[0])){
00051     sprintf(msg, ">> First Input must be a double-precision matrix.\n%s\n", docstring);
00052     mexErrMsgTxt(msg);
00053   } 
00054 
00055   /* getting the appropriate array representation */
00056   Array *binimg = mex_mxarray_to_array( prhs[0] );
00057 
00058   /* computation */
00059   array_typecast( binimg, INT );
00060   Array *dt = disttransform_deadreckoning( binimg, NULL );
00061   plhs[0]=mex_array_to_mxarray( dt ); 
00062 
00063   /* cleaning up */
00064   array_free( binimg );
00065   array_free( dt );
00066 
00067   return;
00068 }
00069         

Generated on Fri Jun 25 2010 14:10:16 for libeegtools by  doxygen 1.7.0