diff --git a/channels/private/convConst.cpp b/channels/private/convConst.cpp index fe5ba4ba..9c5c80e4 100644 --- a/channels/private/convConst.cpp +++ b/channels/private/convConst.cpp @@ -197,7 +197,8 @@ void convMax( float *I, float *O, int h, int w, int d, int r ) { // B=convConst(type,A,r,s); fast 2D convolutions (see convTri.m and convBox.m) #ifdef MATLAB_MEX_FILE void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) { - int *ns, ms[3], nDims, d, m, r, s; float *A, *B, p; + int nDims; float *A, *B, p; + mwSize ms[3]; mwSize *ns, d, m, r, s;; mxClassID id; char type[1024]; // error checking on arguments @@ -205,7 +206,7 @@ void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[] ) { if(nlhs > 1) mexErrMsgTxt("One output expected."); nDims = mxGetNumberOfDimensions(prhs[1]); id = mxGetClassID(prhs[1]); - ns = (int*) mxGetDimensions(prhs[1]); + ns = (mwSize*) mxGetDimensions(prhs[1]); d = (nDims == 3) ? ns[2] : 1; m = (ns[0] < ns[1]) ? ns[0] : ns[1]; if( (nDims!=2 && nDims!=3) || id!=mxSINGLE_CLASS || m<4 ) diff --git a/channels/private/gradientMex.cpp b/channels/private/gradientMex.cpp index dee62960..a41f0ee9 100644 --- a/channels/private/gradientMex.cpp +++ b/channels/private/gradientMex.cpp @@ -318,8 +318,8 @@ void fhog( float *M, float *O, float *H, int h, int w, int binSize, /******************************************************************************/ #ifdef MATLAB_MEX_FILE // Create [hxwxd] mxArray array, initialize to 0 if c=true -mxArray* mxCreateMatrix3( int h, int w, int d, mxClassID id, bool c, void **I ){ - const int dims[3]={h,w,d}, n=h*w*d; int b; mxArray* M; +mxArray* mxCreateMatrix3( mwSize h, mwSize w, mwSize d, mxClassID id, bool c, void **I ){ + const mwSize dims[3]={h,w,d}, n=h*w*d; int b; mxArray* M; if( id==mxINT32_CLASS ) b=sizeof(int); else if( id==mxDOUBLE_CLASS ) b=sizeof(double); else if( id==mxSINGLE_CLASS ) b=sizeof(float); @@ -331,9 +331,9 @@ mxArray* mxCreateMatrix3( int h, int w, int d, mxClassID id, bool c, void **I ){ // Check inputs and outputs to mex, retrieve first input I void checkArgs( int nl, mxArray *pl[], int nr, const mxArray *pr[], int nl0, - int nl1, int nr0, int nr1, int *h, int *w, int *d, mxClassID id, void **I ) + int nl1, int nr0, int nr1, mwSize *h, mwSize *w, mwSize *d, mxClassID id, void **I ) { - const int *dims; int nDims; + const mwSize *dims; int nDims; if( nlnl1 ) mexErrMsgTxt("Incorrect number of outputs."); if( nrnr1 ) mexErrMsgTxt("Incorrect number of inputs."); nDims = mxGetNumberOfDimensions(pr[0]); dims = mxGetDimensions(pr[0]); @@ -344,7 +344,7 @@ void checkArgs( int nl, mxArray *pl[], int nr, const mxArray *pr[], int nl0, // [Gx,Gy] = grad2(I) - see gradient2.m void mGrad2( int nl, mxArray *pl[], int nr, const mxArray *pr[] ) { - int h, w, d; float *I, *Gx, *Gy; + mwSize h, w, d; float *I, *Gx, *Gy; checkArgs(nl,pl,nr,pr,1,2,1,1,&h,&w,&d,mxSINGLE_CLASS,(void**)&I); if(h<2 || w<2) mexErrMsgTxt("I must be at least 2x2."); pl[0]= mxCreateMatrix3( h, w, d, mxSINGLE_CLASS, 0, (void**) &Gx ); @@ -354,7 +354,8 @@ void mGrad2( int nl, mxArray *pl[], int nr, const mxArray *pr[] ) { // [M,O] = gradMag( I, channel, full ) - see gradientMag.m void mGradMag( int nl, mxArray *pl[], int nr, const mxArray *pr[] ) { - int h, w, d, c, full; float *I, *M, *O=0; + mwSize h, w, d; + int c, full; float *I, *M, *O=0; checkArgs(nl,pl,nr,pr,1,2,3,3,&h,&w,&d,mxSINGLE_CLASS,(void**)&I); if(h<2 || w<2) mexErrMsgTxt("I must be at least 2x2."); c = (int) mxGetScalar(pr[1]); full = (int) mxGetScalar(pr[2]); @@ -366,7 +367,7 @@ void mGradMag( int nl, mxArray *pl[], int nr, const mxArray *pr[] ) { // gradMagNorm( M, S, norm ) - operates on M - see gradientMag.m void mGradMagNorm( int nl, mxArray *pl[], int nr, const mxArray *pr[] ) { - int h, w, d; float *M, *S, norm; + mwSize h, w, d; float *M, *S, norm; checkArgs(nl,pl,nr,pr,0,0,3,3,&h,&w,&d,mxSINGLE_CLASS,(void**)&M); if( mxGetM(pr[1])!=h || mxGetN(pr[1])!=w || d!=1 || mxGetClassID(pr[1])!=mxSINGLE_CLASS ) mexErrMsgTxt("M or S is bad."); @@ -376,7 +377,8 @@ void mGradMagNorm( int nl, mxArray *pl[], int nr, const mxArray *pr[] ) { // H=gradHist(M,O,[...]) - see gradientHist.m void mGradHist( int nl, mxArray *pl[], int nr, const mxArray *pr[] ) { - int h, w, d, hb, wb, nChns, binSize, nOrients, softBin, useHog; + mwSize h, w, d, hb, wb; + int nChns, binSize, nOrients, softBin, useHog; bool full; float *M, *O, *H, clipHog; checkArgs(nl,pl,nr,pr,1,3,2,8,&h,&w,&d,mxSINGLE_CLASS,(void**)&M); O = (float*) mxGetPr(pr[1]); diff --git a/channels/private/imPadMex.cpp b/channels/private/imPadMex.cpp index a8363e3e..23338910 100644 --- a/channels/private/imPadMex.cpp +++ b/channels/private/imPadMex.cpp @@ -69,14 +69,15 @@ template void imPad( T *A, T *B, int h, int w, int d, int pt, int pb, // B = imPadMex(A,pad,type); see imPad.m for usage details #ifdef MATLAB_MEX_FILE void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { - int *ns, ms[3], nCh, nDims, pt, pb, pl, pr, flag, k; double *p; + int nCh, nDims, pt, pb, pl, pr, flag, k; double *p; + mwSize *ns, ms[3], *ns_out; void *A, *B; mxClassID id; double val=0; char type[1024]; // Error checking on arguments if( nrhs!=3 ) mexErrMsgTxt("Three inputs expected."); if( nlhs>1 ) mexErrMsgTxt("One output expected."); nDims=mxGetNumberOfDimensions(prhs[0]); id=mxGetClassID(prhs[0]); - ns = (int*) mxGetDimensions(prhs[0]); nCh=(nDims==2) ? 1 : ns[2]; + ns = (mwSize*) mxGetDimensions(prhs[0]); nCh=(nDims==2) ? 1 : ns[2]; if( (nDims!=2 && nDims!=3) || (id!=mxSINGLE_CLASS && id!=mxDOUBLE_CLASS && id!=mxUINT8_CLASS) ) mexErrMsgTxt("A should be 2D or 3D single, double or uint8 array."); @@ -102,10 +103,13 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { if( ns[0]==0 || ns[1]==0 ) flag=0; // create output array - ms[0]=ns[0]+pt+pb; ms[1]=ns[1]+pl+pr; ms[2]=nCh; - if( ms[0]<0 || ns[0]<=-pt || ns[0]<=-pb ) ms[0]=0; - if( ms[1]<0 || ns[1]<=-pl || ns[1]<=-pr ) ms[1]=0; - plhs[0] = mxCreateNumericArray(3, (const mwSize*) ms, id, mxREAL); + ms[0]=ns[0]+mwSize(pt)+mwSize(pb); + ms[1]=ns[1]+mwSize(pl)+mwSize(pr); + ms[2]=mwSize(nCh); + + if( ms[0]<0 || int(ns[0])<=-int(pt) || int(ns[0])<=-int(pb) ) ms[0]=0; + if( ms[1]<0 || int(ns[1])<=-int(pl) || int(ns[1])<=-int(pr) ) ms[1]=0; + plhs[0] = mxCreateNumericArray(3, ms, id, mxREAL); if( ms[0]==0 || ms[1]==0 ) return; // pad array diff --git a/channels/private/imResampleMex.cpp b/channels/private/imResampleMex.cpp index 8d23eebb..00d575fb 100644 --- a/channels/private/imResampleMex.cpp +++ b/channels/private/imResampleMex.cpp @@ -117,7 +117,9 @@ void resample( T *A, T *B, int ha, int hb, int wa, int wb, int d, T r ) { if(ybd[0]==2) for(; y4) for(; y4) { + for(int i=0; i1 ) mexErrMsgTxt("One output expected."); nDims=mxGetNumberOfDimensions(prhs[0]); id=mxGetClassID(prhs[0]); - ns = (int*) mxGetDimensions(prhs[0]); nCh=(nDims==2) ? 1 : ns[2]; + ns = (mwSize*) mxGetDimensions(prhs[0]); nCh=(nDims==2) ? 1 : ns[2]; if( (nDims!=2 && nDims!=3) || (id!=mxSINGLE_CLASS && id!=mxDOUBLE_CLASS && id!=mxUINT8_CLASS) ) mexErrMsgTxt("A should be 2D or 3D single, double or uint8 array."); diff --git a/channels/private/rgbConvertMex.cpp b/channels/private/rgbConvertMex.cpp index bb616da4..6786ed80 100644 --- a/channels/private/rgbConvertMex.cpp +++ b/channels/private/rgbConvertMex.cpp @@ -168,13 +168,14 @@ oT* rgbConvert( iT *I, int n, int d, int flag, oT nrm ) { // J = rgbConvertMex(I,flag,single); see rgbConvert.m for usage details #ifdef MATLAB_MEX_FILE void mexFunction(int nl, mxArray *pl[], int nr, const mxArray *pr[]) { - const int *dims; int nDims, n, d, dims1[3]; void *I; void *J; int flag; + const mwSize *dims; int nDims, n, d; void *I; void *J; int flag; + mwSize dims1[3]; bool single; mxClassID idIn, idOut; // Error checking if( nr!=3 ) mexErrMsgTxt("Three inputs expected."); if( nl>1 ) mexErrMsgTxt("One output expected."); - dims = (const int*) mxGetDimensions(pr[0]); n=dims[0]*dims[1]; + dims = (const mwSize*) mxGetDimensions(pr[0]); n=dims[0]*dims[1]; nDims = mxGetNumberOfDimensions(pr[0]); d = 1; for( int i=2; i