void mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[]) { DOUBLE *hpf,*lpf; DOUBLE *imp,*wcp,*tmp; unsigned int m,n; int nr,nc,nn,J,lenfil,ell; mxArray *temp, *hpfmat; /* Check for proper number of arguments */ if (nrhs != 3) { mexErrMsgTxt("IWT2_PO requires 3 input arguments."); } else if (nlhs != 1) { mexErrMsgTxt("IWT2_PO requires one output argument."); } /* Check the dimensions of signal. signal can be n X 1 or 1 X n. */ m = mxGetM(WC_IN); n = mxGetN(WC_IN); if(m != n){ mexErrMsgTxt("IWT2_PO requires a square array"); } nr = (int) m; nc = nr; J = 0; for( nn = 1; nn < nr; nn *= 2 ) J ++; if( nn != nr){ mexErrMsgTxt("IWT2 requires dyadic length sides"); } /* Create a matrix for the return argument */ Img_OUT = mxCreateDoubleMatrix(nr, nr, mxREAL); temp = mxCreateDoubleMatrix(nr, 4, mxREAL); /* Assign pointers to the various parameters */ imp = mxGetPr(Img_OUT); tmp = mxGetPr(temp); wcp = mxGetPr(WC_IN); ell = floor ((mxGetPr(LLL_IN))[0] + .5); /* should check whether this is in range */ lpf = mxGetPr(LPF_IN); lenfil = (int) (mxGetM(LPF_IN) * mxGetN(LPF_IN)); /* should check this */ hpfmat = mxCreateDoubleMatrix((unsigned int) lenfil, 1, mxREAL); hpf = mxGetPr(hpfmat); mirrorfilt(lpf,hpf,lenfil); /* Do the actual computations in a subroutine */ idpwt2(wcp,nr,nc,ell,J,hpf,lpf,lenfil,imp,tmp); mxDestroyArray(temp); mxDestroyArray(hpfmat); }
void mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[]) { DOUBLE *hpf,*lpf; DOUBLE *sig,*wcp; unsigned int m,n; int nr,nc,nn,J,lenfil,dee; mxArray *temp, *hpfmat; /* Check for proper number of arguments */ if (nrhs != 3) { mexErrMsgTxt("WPAnalysis requires three input arguments."); } else if (nlhs != 1) { mexErrMsgTxt("WPAnalysis requires one output argument."); } /* Check the dimensions of signal. signal can be n X 1 or 1 X n. */ m = mxGetM(Sig_IN); n = mxGetN(Sig_IN); if(m == 1){ nr = (int) n; } else { nr = (int) m; } J = 0; for( nn = 1; nn < nr; nn *= 2 ) J ++; if( nn != nr){ mexErrMsgTxt("WPAnalysis requires dyadic length"); } dee = floor ((mxGetPr(LLL_IN))[0] + .5); /* should check whether this is in range */ lenfil = (int) (mxGetM(LPF_IN) * mxGetN(LPF_IN)); /* should check this */ /* Create a matrix for the return argument */ if( dee > J ){ mexErrMsgTxt("WPAnalysis requires D < log_2(n)"); } if( dee < 0){ mexErrMsgTxt("WPAnalysis requires D >= 0"); } nc = dee+1; WP_OUT = mxCreateDoubleMatrix(nr, nc, mxREAL); temp = mxCreateDoubleMatrix(nr, 4, mxREAL); /* Assign pointers to the various parameters */ wcp = mxGetPr(WP_OUT); sig = mxGetPr(Sig_IN); lpf = mxGetPr(LPF_IN); hpfmat = mxCreateDoubleMatrix((unsigned int) lenfil, 1, mxREAL); hpf = mxGetPr(hpfmat); mirrorfilt(lpf,hpf,lenfil); /* Do the actual computations in a subroutine */ wpd(sig,nr,dee,hpf,lpf,lenfil,wcp,mxGetPr(temp)); mxDestroyArray(temp); mxDestroyArray(hpfmat); }
void mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[]) { DOUBLE *hpf,*lpf; DOUBLE *sig,*wcp,*wcp1,*wcp2; /* unsigned int m,n; */ int nr,nc,nn,mm,kk,J,lenfil,dee; mxArray *temp, *hpfmat, *WP_OUT1, *WP_OUT2; /* Check for proper number of arguments */ if (nrhs != 3) { mexErrMsgTxt("rec_wp_decomp1 requires three input arguments."); } else if (nlhs != 1) { mexErrMsgTxt("rec_wp_decomp1 requires one output argument."); } /* Check the dimensions of signal. signal can be n X 1 or 1 X n. */ nr = mxGetM(Sig_IN); nc = mxGetN(Sig_IN); J = 0; for( nn = 1; nn < nc; nn *= 2 ) J ++; if( nn != nc){ mexErrMsgTxt("rec_wp_decomp1 requires dyadic length"); } J = 0; for( nn = 1; nn < nr; nn *= 2 ) J ++; if( nn != nr){ mexErrMsgTxt("rec_wp_decomp1 requires dyadic length"); } WP_OUT = mxCreateDoubleMatrix(nr, nc, mxREAL); sig = mxGetPr(Sig_IN); wcp = mxGetPr(WP_OUT); lenfil = (int) (mxGetM(LPF_IN) * mxGetN(LPF_IN)); /* should check this */ lpf = mxGetPr(LPF_IN); hpfmat = mxCreateDoubleMatrix((unsigned int) lenfil, 1, mxREAL); hpf = mxGetPr(hpfmat); mirrorfilt(lpf,hpf,lenfil); for( kk = 0; kk < mxGetN(LLL_IN); kk++) { dee = floor ((mxGetPr(LLL_IN))[kk] + .5); /* should check whether this is in range */ /* Create a matrix for the return argument */ if( dee > J ){ mexErrMsgTxt("rec_wp_decomp1 requires D < log_2(n)"); } if( dee < 0){ mexErrMsgTxt("rec_wp_decomp1 requires D >= 0"); } nn = dee+1; for( mm = nc/2; mm < nc; mm++){ WP_OUT1 = mxCreateDoubleMatrix(nr, nn, mxREAL); WP_OUT2 = mxCreateDoubleMatrix(nr, 1, mxREAL); temp = mxCreateDoubleMatrix(nr, 6, mxREAL); /* Assign pointers to the various parameters */ wcp1 = mxGetPr(WP_OUT1); wcp2 = mxGetPr(WP_OUT2); copydouble(&sig[mm*nr],wcp2,nr); /* Do the actual computations in a subroutine */ wpd(wcp2,nr,dee,hpf,lpf,lenfil,wcp1,mxGetPr(temp)); copydouble(&wcp1[0],&wcp[mm*nr],nr); mxDestroyArray(temp); } nc = nc/2; } mxDestroyArray(hpfmat); }