how to call imresize in mex file(MATLAB)
I have written the following code to use imresize
function in mex file.
#include "mex.h"
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, mxArray *prhs[])
{
mxArray *output[1];
mxArray *input[3];
input[0] = prhs[0];
input[1] = mxCreateDoubleMatrix(1, 1, mxCOMPLEX);
double *x = mxGetPr(input[1]);
x[0] = 0.5;
//double *p = mxGetPr(input[1]);
//mexPrintf("%f\n", p[0]);
input[2] = mxCreateString("bilinear");
mexCallMATLAB(0, NULL, 1, &prhs[0], "imshow");
mexCallMATLAB(1, output, 3, input, "imr开发者_如何学JAVAesize");
mexCallMATLAB(0, NULL, 1, &output[0], "imshow");
}
It gives an error: Function IMRESIZE expected its second input, SCALE, to be nonzero.
How can I fix it?
So just try to replace the following code:
input[1] = mxCreateDoubleMatrix(1, 1, mxCOMPLEX);
double *x = mxGetPr(input[1]);
x[0] = 0.5;
with this line
input[1]=mxCreateDoubleScalar(0.5);
精彩评论