IplImage* warp(IplImage* img, Eigen::Matrix3d const & H, Eigen::Vector4d const & box) { int w, h; double *result; double xmin, xmax, ymin, ymax, fill; w = img->width; h = img->height; xmin = box(0); xmax = box(1); ymin = box(2); ymax = box(3); fill = 0; result = new double[((int) (xmax - xmin + 1) * (int) (ymax - ymin + 1))]; { warp_image_roi(img, w, h, H, xmin, xmax, ymin, ymax, fill, result); } IplImage* out = toIpl(result, (int) (xmax - xmin + 1), (int) (ymax - ymin + 1)); delete[] result; return out; }
void mexFunction (int nlhs, mxArray *plhs [], int nrhs, const mxArray *prhs []) { int w, h; unsigned char *im; double *result; double *H = 0; double xmin, xmax, ymin, ymax, fill; if (nrhs>0) { w = mxGetN(prhs[0]); h = mxGetM(prhs[0]); im = (unsigned char*) mxGetPr(prhs[0]); //from_matlab(prhs[0], &im, &w, &h); if (nrhs>1) H = (double *)mxGetData(prhs[1]); if (nrhs>2 && mxGetM(prhs[2])>0) { double *B; B = (double*)mxGetData(prhs[2]); xmin = (*B++); xmax = (*B++); ymin = (*B++); ymax = (*B++); } else { xmin = ymin = 0; xmax = w-1; ymax = h-1; } if (nrhs>3) fill=0; else fill=0; result=new double[((int)(xmax-xmin+1)*(int)(ymax-ymin+1))]; { warp_image_roi(im, w, h, H, xmin, xmax, ymin, ymax, fill, result); } plhs[0]=to_matlab(result, (int)(xmax-xmin+1), (int)(ymax-ymin+1)); delete [] result; } }