how to convert MATLAB code to c code for a functions which is using a string as a parameters?

2 ビュー (過去 30 日間)
sh.bill
sh.bill 2015 年 11 月 13 日
コメント済み: Troy Cumbo 2016 年 2 月 18 日
HI!
Firstly, I'm really surprised Mathwork's fast update for Image Processing Toolbox functions for MATLAB code generator. It's pretty awesome.
Now I'm in big trouble on code generator......
When i try to use morphological filters ( like imopen, imdelation, imelode... ), we use 'strel' function to make elements
and I'm trying to convert strel function on matlab to c code
but the code generator said "All inputs must be constant."
because input parameter of strel function is string which means type of element
I think this string causes this error......
.
how can i solve this problem????
plz help me
thx
  1 件のコメント
Troy Cumbo
Troy Cumbo 2016 年 2 月 18 日
Is the radius of your strel function a constant value, or is it a variable?
In my experience with Coder, the app will correctly generate code if the arguments to strel are constants. Moreover, your structuring element must also be a constant in order for it to be used by the morphological functions (imopen, etc.).
So while this should work:
X = strel('disk', 5);
This will not:
X = strel(sStrelType, dStrelSize);
If you need variable-sized structuring elements, this can be a real pain, because you can't even make arrays of strels. I worked around those limitations by constructing several constant structuring elements and then using them in separate imtophat calls in the case branches of a switch statement. Very unpretty, but it works.

サインインしてコメントする。

回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by