4

我编写了以下代码来使用imresizemex 文件中的函数。

   #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, "imresize");
mexCallMATLAB(0, NULL, 1, &output[0], "imshow");    
    }

它给出了一个错误:Function IMRESIZE expected its second input, SCALE, to be nonzero.我该如何解决它?

4

1 回答 1

1

所以只需尝试替换以下代码:

input[1] = mxCreateDoubleMatrix(1, 1, mxCOMPLEX);
double *x = mxGetPr(input[1]);
x[0] = 0.5;

用这条线

 input[1]=mxCreateDoubleScalar(0.5);
于 2013-05-09T06:45:12.780 回答