/* u = fwt2_CWT(x, h0_r, h1_r, h0_c, h1_c, J, symr, symc); */ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { double *u, *w, *h0_r, *h1_r, *h0_c, *h1_c; int nR, nC, l, l1, symr, symc, J, JmaxR, JmaxC; /* Check for the proper number of arguments. */ if (nrhs != 8) { mexErrMsgTxt("Exactly five inputs required"); } if (nlhs > 1) { mexErrMsgTxt("Too many output arguments"); } nR = mxGetM(prhs[0]); nC = mxGetN(prhs[0]); /* * if (n != n1) { mexErrMsgTxt("Input w must be a square image."); } */ if (mxIsComplex(prhs[0])) { mexErrMsgTxt("Input w must be real"); } J = mxGetScalar(prhs[5]); JmaxR = checkPowerTwo(nR, J); JmaxC = checkPowerTwo(nC, J); if ((J < 0) || (J > JmaxR) || (J > JmaxC) ) { mxErrMsgTxt("Input J must be an integer between 0 and log2(n), and dyadic for ROW and COL---use smaller J."); } l = (mxGetM(prhs[1]) > mxGetN(prhs[1])) ? mxGetM(prhs[1]) : mxGetN(prhs[1]); l1 = (mxGetM(prhs[2]) > mxGetN(prhs[2])) ? mxGetM(prhs[2]) : mxGetN(prhs[2]); if (l != l1) { mexErrMsgTxt("Filters must be the same length"); } symr = mxGetScalar(prhs[6]); symc = mxGetScalar(prhs[7]); if ((symr > 2) || (symc > 2)) { mexErrMsgTxt("Symmetry flag must be 0, 1, or 2"); } /* Create matrix for the return argument. */ plhs[0] = mxCreateDoubleMatrix(nR, nC, mxREAL); /* Assign pointers to each input and output. */ w = mxGetPr(prhs[0]); h0_r = mxGetPr(prhs[1]); h1_r = mxGetPr(prhs[2]); h0_c = mxGetPr(prhs[3]); h1_c = mxGetPr(prhs[4]); u = mxGetPr(plhs[0]); /* Call the C subroutine. */ adj_wavelet_multi_level2D_CWT(u, w, nR, nC, h0_r, h1_r, h0_c, h1_c, l, J, symr, symc); return; }
/* u = afwt(w, h0, h1, J, sym); */ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { double *u, *w, *h0, *h1; int n, l, l1, sym, J, Jmax; /* Check for the proper number of arguments. */ if (nrhs != 5) { mexErrMsgTxt("Exactly five inputs required"); } if (nlhs > 1) { mexErrMsgTxt("Too many output arguments"); } if (mxGetN(prhs[0]) > 1) { mexErrMsgTxt("Input x must be a column vector"); } if (mxIsComplex(prhs[0])) { mexErrMsgTxt("Input w must be real"); } n = mxGetM(prhs[0]); J = mxGetScalar(prhs[3]); Jmax = checkPowerTwo(n, J); if ((J < 0) || (J > Jmax)) { mxErrMsgTxt("Input J must be an integer between 0 and log2(n)"); } l = (mxGetM(prhs[1]) > mxGetN(prhs[1])) ? mxGetM(prhs[1]) : mxGetN(prhs[1]); l1 = (mxGetM(prhs[2]) > mxGetN(prhs[2])) ? mxGetM(prhs[2]) : mxGetN(prhs[2]); if (l != l1) { mexErrMsgTxt("Filters must be the same length"); } sym = mxGetScalar(prhs[4]); if (sym > 2) { mexErrMsgTxt("Symmetry flag must be 0, 1, or 2"); } /* Create matrix for the return argument. */ plhs[0] = mxCreateDoubleMatrix(n, 1, mxREAL); /* Assign pointers to each input and output. */ w = mxGetPr(prhs[0]); h0 = mxGetPr(prhs[1]); h1 = mxGetPr(prhs[2]); u = mxGetPr(plhs[0]); /* Call the C subroutine. */ adj_wavelet_multi_level(u, w, n, h0, h1, l, J, sym); return; }
/* The gateway routine. */ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { double *x, *y; unsigned m, n; /* Check for the proper number of arguments. */ if (nrhs != 1) { mexErrMsgTxt("One and only one input required; must be a column vector or matrix, with # rows a power of 2."); } if (nlhs > 1) { mexErrMsgTxt("Too many output arguments."); } /* input size */ m = mxGetM(prhs[0]); checkPowerTwo(m); n = mxGetN(prhs[0]); if (mxIsComplex(prhs[0])) { mexErrMsgTxt("Input must be real."); } else if (mxIsSparse(prhs[0])) { mexErrMsgTxt("Input must be a full matrix, not sparse."); } else if (!mxIsDouble(prhs[0])) { mexErrMsgTxt("Input must be of type double."); } /* Create matrix for the return argument. */ plhs[0] = mxCreateDoubleMatrix(m, n, mxREAL); /* Assign pointers to each input and output. */ x = mxGetPr(prhs[0]); y = mxGetPr(plhs[0]); /* Call the C subroutine. */ hadamard_apply_matrix(y, x, m, n); return; }
/* x = ifwt2_CWT(w, g0_r, g1_r, g0_c, g1_c, J, symr, symc, rosym_flip, cosym_flip); */ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { double *x, *w, *g0_r, *g1_r, *g0_c, *g1_c; int nR, nC, l, l1, symr, symc, rosym_flip, cosym_flip, J, JmaxR, JmaxC; /* Check for the proper number of arguments. */ if (nrhs != 10) { mexErrMsgTxt("Exactly ten inputs required"); } if (nlhs > 1) { mexErrMsgTxt("Too many output arguments"); } nR = mxGetM(prhs[0]); nC = mxGetN(prhs[0]); /* * if (n != n1) { mexErrMsgTxt("Input w must be a square image."); } */ if (mxIsComplex(prhs[0])) { mexErrMsgTxt("Input w must be real"); } J = mxGetScalar(prhs[5]); JmaxR = checkPowerTwo(nR, J); JmaxC = checkPowerTwo(nC, J); if ((J < 0) || (J > JmaxR) || (J > JmaxC) ) { mxErrMsgTxt("Input J must be an integer between 0 and log2(n), and dyadic for ROW and COL---use smaller J."); } l = (mxGetM(prhs[1]) > mxGetN(prhs[1])) ? mxGetM(prhs[1]) : mxGetN(prhs[1]); l1 = (mxGetM(prhs[2]) > mxGetN(prhs[2])) ? mxGetM(prhs[2]) : mxGetN(prhs[2]); if (l != l1) { mexErrMsgTxt("Filters must be the same length"); } symr = mxGetScalar(prhs[6]); symc = mxGetScalar(prhs[7]); rosym_flip = mxGetScalar(prhs[8]); /* tells if we need to flip odd symmetry of scaling and wavelet coeffs */ cosym_flip = mxGetScalar(prhs[9]); /* mexPrintf("rosym_flip is %d, cosym_flip is %d, \n", rosym_flip, cosym_flip); */ if ((symr > 2) || (symc > 2)) { mexErrMsgTxt("Symmetry flag must be 0, 1, or 2"); } /* Create matrix for the return argument. */ plhs[0] = mxCreateDoubleMatrix(nR, nC, mxREAL); /* Assign pointers to each input and output. */ w = mxGetPr(prhs[0]); g0_r = mxGetPr(prhs[1]); g1_r = mxGetPr(prhs[2]); g0_c = mxGetPr(prhs[3]); g1_c = mxGetPr(prhs[4]); x = mxGetPr(plhs[0]); /* Call the C subroutine. */ inv_wavelet_multi_level2D_CWT(x, w, nR, nC, g0_r, g1_r, g0_c, g1_c, l, J, symr, symc, rosym_flip, cosym_flip); return; }