From: sakshi j on
Hi,
I'm trying to run the following piece of code:
void mexFunction(
int nlhs,
mxArray *[],
int nrhs,
const mxArray *prhs[]
)
{


using namespace libbase;


vector <double> y;



double *xValues;

int i,j;



mxArray *value;





xValues = mxGetPr(prhs[0]);

int rowLen = mxGetN(prhs[0]);
int colLen = mxGetM(prhs[0]);


y.init(2);
y=0;

y(1)=3;
y(2)=3;



printf("the rowlength is=%d",rowLen);

value = mxDuplicateArray(prhs[0]);





double neigh[] = {3,3};
double *pr;
mxArray *p;




int nlhs1, nrhs1;
mxArray *plhs1[2], *prhs1[2];


nlhs1 = 2;
nrhs1 = 2;
prhs1[0]=value;


prhs1[1] = mxCreateCellMatrix(2, 1);
pr = mxGetPr(prhs1[1]);
for( i=0; i<=1; i++ ) {
pr[i] = neigh[i];
}

mxSetCell(*p,1, );
mexCallMATLAB(nlhs1,plhs1,nrhs1,prhs1,"wiener2");


return;

}

i first run the following:
a = im2double(imread('stego.tif'))'

Then i compile my mex file.
And I recieve the following output with this error:
the rowlength is=256the value of neigh is=0.000000the value of neigh is=3.000000??? Error using ==> ones
Size vector must be a row vector with real elements.

Error in ==> wiener2 at 55
localMean = filter2(ones(nhood), g) / prod(nhood);


Can anybody help me in this regard?
From: sakshi j on
Hi,
I'm trying to run the following piece of code:
void mexFunction(
int nlhs,
mxArray *[],
int nrhs,
const mxArray *prhs[]
)
{


using namespace libbase;


vector <double> y;



double *xValues;

int i,j;



mxArray *value;





xValues = mxGetPr(prhs[0]);

int rowLen = mxGetN(prhs[0]);
int colLen = mxGetM(prhs[0]);


y.init(2);
y=0;

y(1)=3;
y(2)=3;



printf("the rowlength is=%d",rowLen);

value = mxDuplicateArray(prhs[0]);





double neigh[] = {3,3};
double *pr;
mxArray *p;




int nlhs1, nrhs1;
mxArray *plhs1[2], *prhs1[2];


nlhs1 = 2;
nrhs1 = 2;
prhs1[0]=value;


prhs1[1] = mxCreateCellMatrix(2, 1);
pr = mxGetPr(prhs1[1]);
for( i=0; i<=1; i++ ) {
pr[i] = neigh[i];
}

mxSetCell(*p,1, );
mexCallMATLAB(nlhs1,plhs1,nrhs1,prhs1,"wiener2");


return;

}

i first run the following:
a = im2double(imread('stego.tif'))'

Then i compile my mex file.
And I recieve the following output with this error:
the rowlength is=256the value of neigh is=0.000000the value of neigh is=3.000000??? Error using ==> ones
Size vector must be a row vector with real elements.

Error in ==> wiener2 at 55
localMean = filter2(ones(nhood), g) / prod(nhood);


Can anybody help me in this regard?
From: sakshi j on
"James Tursa" <aclassyguy_with_a_k_not_a_c(a)hotmail.com> wrote in message <h77sbr$p8s$1(a)fred.mathworks.com>...
> "Ramana murthy" <omurthy(a)yahoo.com> wrote in message <h77k3d$bs4$1(a)fred.mathworks.com>...
> > Hi James,
> >
> > One small doubt.
> > Suppose I call interp1.m (matlab in-built function) in mex file.
> > Will it's Execution time be less than what if it were to be called in a matlab script file?
> > with same data, of course.
> >
> > I have one application (m file) where I am calling some 256x256x3 times the interp1.m function. If I send the data into mex routine and call interp1.m from mex file, compute and send the results back to m file, will it take less time?
> >
> > with regards,
> > ramana
>
> No. Passing the variable to a mex file and then calling interp1 with mexCallMATLAB is going to take the same amount of time as calling it directly from a script file ... you are calling the exact same function in either case. In general, any m-file called from a mex routine with mexCallMATLAB is going to take at least as long as calling the same m-file from a script file. In some cases it can even take longer, because an m-file called from a script is allowed to return a shared data copy, whereas the same m-file called from a mex routine with mexCallMATLAB is prevented from returning a shared data copy ... so extra work may have to be done for the same call from a mex routine. I suspect MATLAB enforces this for mexCallMATLAB to make sure there is no unintended data corruption downstream in the mex routine.
>
> Situations where mex files shine is when there are a huge number of intermediate variables (matrix slices, etc.) that create a lot of overhead when coded in MATLAB, but all this overhead can potentially be saved by recoding the same algorithm in a mex routine. If the overhead is significant, the mex routine can significantly outperform the m-code.
>
> James Tursa

Hi,
I'm trying to run the following piece of code:
void mexFunction(
int nlhs,
mxArray *[],
int nrhs,
const mxArray *prhs[]
)
{


using namespace libbase;


vector <double> y;



double *xValues;

int i,j;



mxArray *value;





xValues = mxGetPr(prhs[0]);

int rowLen = mxGetN(prhs[0]);
int colLen = mxGetM(prhs[0]);


y.init(2);
y=0;

y(1)=3;
y(2)=3;



printf("the rowlength is=%d",rowLen);

value = mxDuplicateArray(prhs[0]);





double neigh[] = {3,3};
double *pr;
mxArray *p;




int nlhs1, nrhs1;
mxArray *plhs1[2], *prhs1[2];


nlhs1 = 2;
nrhs1 = 2;
prhs1[0]=value;


prhs1[1] = mxCreateCellMatrix(2, 1);
pr = mxGetPr(prhs1[1]);
for( i=0; i<=1; i++ ) {
pr[i] = neigh[i];
}

mxSetCell(*p,1, );
mexCallMATLAB(nlhs1,plhs1,nrhs1,prhs1,"wiener2");


return;

}

i first run the following:
a = im2double(imread('stego.tif'))'

Then i compile my mex file.
And I recieve the following output with this error:
the rowlength is=256the value of neigh is=0.000000the value of neigh is=3.000000??? Error using ==> ones
Size vector must be a row vector with real elements.

Error in ==> wiener2 at 55
localMean = filter2(ones(nhood), g) / prod(nhood);


Can anybody help me in this regard?
From: sakshi j on
"sakshi j" <sakshi399(a)yahoo.co.in> wrote in message <hvt191$o3f$1(a)fred.mathworks.com>...
> Hi,
> I'm trying to run the following piece of code:
> void mexFunction(
> int nlhs,
> mxArray *[],
> int nrhs,
> const mxArray *prhs[]
> )
> {
>
>
> using namespace libbase;
>
>
> vector <double> y;
>
>
>
> double *xValues;
>
> int i,j;
>
>
>
> mxArray *value;
>
>
>
>
>
> xValues = mxGetPr(prhs[0]);
>
> int rowLen = mxGetN(prhs[0]);
> int colLen = mxGetM(prhs[0]);
>
>
> y.init(2);
> y=0;
>
> y(1)=3;
> y(2)=3;
>
>
>
> printf("the rowlength is=%d",rowLen);
>
> value = mxDuplicateArray(prhs[0]);
>
>
>
>
>
> double neigh[] = {3,3};
> double *pr;
> mxArray *p;
>
>
>
>
> int nlhs1, nrhs1;
> mxArray *plhs1[2], *prhs1[2];
>
>
> nlhs1 = 2;
> nrhs1 = 2;
> prhs1[0]=value;
>
>
> prhs1[1] = mxCreateCellMatrix(2, 1);
> pr = mxGetPr(prhs1[1]);
> for( i=0; i<=1; i++ ) {
> pr[i] = neigh[i];
> }
>
> mxSetCell(*p,1, );
> mexCallMATLAB(nlhs1,plhs1,nrhs1,prhs1,"wiener2");
>
>
> return;
>
> }
>
> i first run the following:
> a = im2double(imread('stego.tif'))'
>
> Then i compile my mex file.
> And I recieve the following output with this error:
> the rowlength is=256the value of neigh is=0.000000the value of neigh is=3.000000??? Error using ==> ones
> Size vector must be a row vector with real elements.
>
> Error in ==> wiener2 at 55
> localMean = filter2(ones(nhood), g) / prod(nhood);
>
>
> Can anybody help me in this regard?


SORRY...correction(this is the erraneous code):
Hi,
I'm trying to run the following piece of code:
void mexFunction(
int nlhs,
mxArray *[],
int nrhs,
const mxArray *prhs[]
)
{


using namespace libbase;


vector <double> y;



double *xValues;

int i,j;



mxArray *value;





xValues = mxGetPr(prhs[0]);

int rowLen = mxGetN(prhs[0]);
int colLen = mxGetM(prhs[0]);


y.init(2);
y=0;

y(1)=3;
y(2)=3;



printf("the rowlength is=%d",rowLen);

value = mxDuplicateArray(prhs[0]);





double neigh[] = {3,3};
double *pr;
mxArray *p;




int nlhs1, nrhs1;
mxArray *plhs1[2], *prhs1[2];


nlhs1 = 2;
nrhs1 = 2;
prhs1[0]=value;


prhs1[1] = mxCreateDoubleMatrix(2, 1);
pr = mxGetPr(prhs1[1]);
for( i=0; i<=1; i++ ) {
pr[i] = neigh[i];
}


mexCallMATLAB(nlhs1,plhs1,nrhs1,prhs1,"wiener2");


return;

}

i first run the following:
a = im2double(imread('stego.tif'))'

Then i compile my mex file.
And I recieve the following output with this error:
the rowlength is=256the value of neigh is=0.000000the value of neigh is=3.000000??? Error using ==> ones
Size vector must be a row vector with real elements.

Error in ==> wiener2 at 55
localMean = filter2(ones(nhood), g) / prod(nhood);


Can anybody help me in this regard?