Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues while testing on a new image #4

Open
anjali-chadha opened this issue Oct 29, 2018 · 15 comments
Open

Issues while testing on a new image #4

anjali-chadha opened this issue Oct 29, 2018 · 15 comments

Comments

@anjali-chadha
Copy link

I am trying to run the dehazing model on the provided sample image 'data/girls.jpg'.
Got the following error at dehazing step

>> dehaze = run_cnn(haze);
Error using convConst
A must be a 4x4 or bigger 2D or 3D float array.

Error in convMax (line 52)
        convConst('convMax',convConst('convMax',J(:,:,z),ry,1)',rx,1)';
        end

Error in run_cnn (line 29)
F3=convMax(single(F2), 3);

@xiaofeng94
Copy link

Hi, @anjali-chadha
I have met the same problem when just running the default demo.m, have you solved it?

@xiaofeng94
Copy link

xiaofeng94 commented Nov 14, 2018

I solved this problem by making the following modifications.

  1. change
int *ns;
ns = (int*) mxGetDimensions(prhs[1]);

to

const size_t *ns = mxGetDimensions(prhs[1]);
  1. change
int ms[3]
...
mxSetDimensions(plhs[0],(mwSize*)ms,nDims);

to

size_t ms[3]
...
mxSetDimensions(plhs[0],ms,nDims);

It seems that casting size_t* (or mwSize*) to int* is not proper in x64 PC.

@Malfurion-Learns-IELTS
Copy link

I am trying to run the dehazing model on the provided sample image 'data/girls.jpg'.
Got the following error at dehazing step

>> dehaze = run_cnn(haze);
Error using convConst
A must be a 4x4 or bigger 2D or 3D float array.

Error in convMax (line 52)
        convConst('convMax',convConst('convMax',J(:,:,z),ry,1)',rx,1)';
        end

Error in run_cnn (line 29)
F3=convMax(single(F2), 3);

Did you fix this problem?

@Malfurion-Learns-IELTS
Copy link

I solved this problem by making the following modifications.

  1. change
int *ns;
ns = (int*) mxGetDimensions(prhs[1]);

to

const size_t *ns = mxGetDimensions(prhs[1]);
  1. change
int ms[3]
...
mxSetDimensions(plhs[0],(mwSize*)ms,nDims);

to

size_t ms[3]
...
mxSetDimensions(plhs[0],ms,nDims);

It seems that casting size_t* (or mwSize*) to int* is not proper in x64 PC.

I have used your method. But it doesn't work. Can I send you an email to ask your guide?

@caibolun
Copy link
Owner

I solved this problem by making the following modifications.

  1. change
int *ns;
ns = (int*) mxGetDimensions(prhs[1]);

to

const size_t *ns = mxGetDimensions(prhs[1]);
  1. change
int ms[3]
...
mxSetDimensions(plhs[0],(mwSize*)ms,nDims);

to

size_t ms[3]
...
mxSetDimensions(plhs[0],ms,nDims);

It seems that casting size_t* (or mwSize*) to int* is not proper in x64 PC.

I have used your method. But it doesn't work. Can I send you an email to ask your guide?

You can use F3=ordfilt2(F2, 49, ones(7,7)); to replace F3=convMax(single(F2), 3);. Here, convMax is used to speedup Max pooling.

@Leslli
Copy link

Leslli commented Dec 3, 2020

I am trying to run the dehazing model on the provided sample image 'data/girls.jpg'.
Got the following error at dehazing step

>> dehaze = run_cnn(haze);
Error using convConst
A must be a 4x4 or bigger 2D or 3D float array.

Error in convMax (line 52)
        convConst('convMax',convConst('convMax',J(:,:,z),ry,1)',rx,1)';
        end

Error in run_cnn (line 29)
F3=convMax(single(F2), 3);

Did you fix this problem?
You could change the parameters like this.

void mexFunction( int nlhs, mxArray* plhs[], int nrhs, mxArray* prhs[] ) {
  int nDims, d, m, r, s; float *A, *B, p;
  const mwSize *ns = mxGetDimensions(prhs[1]);
  mwSize ms[3];

@Reiko-9k
Copy link

Reiko-9k commented May 7, 2021

我通过以下修改解决了这个问题。

  1. 改变
int *ns;
ns = (int*) mxGetDimensions(prhs[1]);

const size_t *ns = mxGetDimensions(prhs[1]);
  1. 改变
int ms[3]
...
mxSetDimensions(plhs[0],(mwSize*)ms,nDims);

size_t ms[3]
...
mxSetDimensions(plhs[0],ms,nDims);

看来在 x64 PC 中将size_t*(或 mwSize*) 投到 int* 是不合适的。

我用了你的方法。但它不起作用。我可以给你发一封电子邮件,问你的导游吗?

Excuse me, have you solved this problem?

@SchulerTsang
Copy link

I solved this problem by making the following modifications.

  1. change
int *ns;
ns = (int*) mxGetDimensions(prhs[1]);

to

const size_t *ns = mxGetDimensions(prhs[1]);
  1. change
int ms[3]
...
mxSetDimensions(plhs[0],(mwSize*)ms,nDims);

to

size_t ms[3]
...
mxSetDimensions(plhs[0],ms,nDims);

It seems that casting size_t* (or mwSize*) to int* is not proper in x64 PC.

I have used your method. But it doesn't work. Can I send you an email to ask your guide?

You can use F3=ordfilt2(F2, 49, ones(7,7)); to replace F3=convMax(single(F2), 3);. Here, convMax is used to speedup Max pooling.

I did the the replacement opreration as your instrution,Howerover, another error occured.Below are the error details:
错误使用 convConst
A must be a 4x4 or bigger 2D or 3D float array.

出错 convMax (line 52)
convConst('convMax',convConst('convMax',J(:,:,z),ry,1)',rx,1)';
end

出错 run_cnn (line 29)
F3=convMax(single(F2), 3);

dehaze = run_cnn(haze);
错误使用 ordfilt2
第 1 个输入, A, 应为 二维。

出错 ordfilt2>ParseInputs (line 151)
validateattributes(A, ...

出错 ordfilt2 (line 51)
[A,order,domain,s,padopt,~] = ParseInputs(args{:});

出错 run_cnn (line 30)
F3=ordfilt2(F2, 49, ones(7,7));
any suggestion?

@FullAutoCapitalism
Copy link

I solved this problem by making the following modifications.

  1. change
int *ns;
ns = (int*) mxGetDimensions(prhs[1]);

to

const size_t *ns = mxGetDimensions(prhs[1]);
  1. change
int ms[3]
...
mxSetDimensions(plhs[0],(mwSize*)ms,nDims);

to

size_t ms[3]
...
mxSetDimensions(plhs[0],ms,nDims);

It seems that casting size_t* (or mwSize*) to int* is not proper in x64 PC.

Birlliant

@kzq666666
Copy link

I tried the solution above, but they don't work, Can someone give me an answer?Thanks very much!

@jsbhxmj
Copy link

jsbhxmj commented Mar 6, 2023

错误使用 convConst
A must be a 4x4 or bigger 2D or 3D float array.

出错 convMax (第 52 行)
convConst('convMax',convConst('convMax',J(:,:,z),ry,1)',rx,1)'; end

出错 run_cnn (第 29 行)
F3=convMax(single(F2), 3);

在MATLAB上运行遇到如上问题,求助应该如何解决

@Yshelgi
Copy link

Yshelgi commented Mar 10, 2023

I solved this problem by making the following modifications.

  1. change
int *ns;
ns = (int*) mxGetDimensions(prhs[1]);

to

const size_t *ns = mxGetDimensions(prhs[1]);
  1. change
int ms[3]
...
mxSetDimensions(plhs[0],(mwSize*)ms,nDims);

to

size_t ms[3]
...
mxSetDimensions(plhs[0],ms,nDims);

It seems that casting size_t* (or mwSize*) to int* is not proper in x64 PC.

Thanks,that's useful

@Chengyunlai
Copy link

I tried these solutions, it seems to have no effect, plus the author said that the error will not report this "" A must be a 4x4 or bigger 2D or 3D float array." but will report the number of parameters error

@TuJiaX
Copy link

TuJiaX commented Dec 6, 2024

@SchulerTsang If you meet error like:"错误使用 ordfilt2 第 1 个输入, A, 应为二维"
you should not directly use F3=ordfilt2(single(F2),49, ones(7,7));
instead, you should operate ordfilt2 to every pages of F2, then concatenate all the results.
for i=1:size(F2,3) F3(:,:,iii)=ordfilt2(single(F2(:,:,iii)),49, ones(7,7)); end

@VoidVampire
Copy link

Thanks for the fix @xiaofeng94, I tried it on MATLAB Online and it's working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests