#include "mex.h" #include #include #include #include #define index(A,B,C,DIM) ((C)*DIM[0]*DIM[1] + (B)*DIM[0] + (A)) #ifndef PI #define PI 3.14159265358979 #endif #ifndef MIN #define MIN(A,B) ((A) > (B) ? (B) : (A)) #endif #ifndef MAX #define MAX(A,B) ((A) > (B) ? (A) : (B)) #endif double wrap(double angle) { while (angle > PI) {angle -= 2*PI;} while (angle < -PI) {angle += 2*PI;} return(angle); } void estimate_ramps(double *pm, double *mask, mwSize dim[3], double ramp[3]) { mwIndex i=0, j=0, k=0; int nx=0, ny=0, nz=0; int c=0, ci=0, cj=0, ck=0; for (i=0; i 3)) { mexErrMsgTxt("pm_estimate_ramp: pm must be 2 or 3-dimensional"); } cdim = mxGetDimensions(prhs[0]); pm = mxGetPr(prhs[0]); /* Get mask. */ if (!mxIsNumeric(prhs[1]) || mxIsComplex(prhs[1]) || mxIsSparse(prhs[1]) || !mxIsDouble(prhs[1])) { mexErrMsgTxt("pm_estimate_ramp: pm must be numeric, real, full and double"); } mask_ndim = mxGetNumberOfDimensions(prhs[1]); if (mask_ndim != ndim) { mexErrMsgTxt("pm_estimate_ramp: pm and mask must have same dimensionality"); } mask_cdim = mxGetDimensions(prhs[1]); for (i=0; i