// 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; 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."); S = (float*) mxGetPr(pr[1]); norm = (float) mxGetScalar(pr[2]); gradMagNorm(M,S,h,w,norm); }
GradMagChannel::GradMagChannel(const ColorChannel& CC) { // std::cout << "We work with a " << CC.getWidth() << "x" << CC.getHeight() << " image with " << CC.getnChns() << " channels" << std::endl; int w = CC.getWidth(); int h = CC.getHeight(); int nchns = CC.getnChns(); this->mag = (float*)malloc(sizeof(float) * w * h); // only one channel deep this->orientation = (float*)malloc(sizeof(float) * w * h); gradMag(CC.getData(), mag, orientation, h, w, nchns, 0); float* S = (float*)malloc(sizeof(float) * w * h); convTri(mag, S, h, w, 1, 5, 1); gradMagNorm(mag, S, h, w, 0.0050); //Smoothing is performed, so delete the temporary data free(S); // Set the magnitude as the data to use for this channel setChanneldata(mag, w, h, 1); }