how to use "imresize" in mex file

1 vue (au cours des 30 derniers jours)
zhang
zhang le 13 Avr 2011
Hi guys
I have wrote the following code to use "imresize" function in mex file.
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");
}
But it always gives me the error "Function IMRESIZE expected its second input, SCALE, to be nonzero." Actually, I use "mexPrintf" to print the content of input[1]. It's 0.5. Can anyone tell me what does happen?
Thanks,
Zhong

Réponses (1)

zhang
zhang le 14 Avr 2011
This problem is kind of solved.
I use
input[1]=mxCreateDoubleScalar(0.5);
to replace
input[1] = mxCreateDoubleMatrix(1, 1, mxCOMPLEX);
double *x = mxGetPr(input[1]);
x[0] = 0.5;
And the it works.

Catégories

En savoir plus sur Write C Functions Callable from MATLAB (MEX Files) dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by