how to convert MATLAB code to c code for a functions which is using a string as a parameters?
2 views (last 30 days)
Show older comments
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 Comment
Troy Cumbo
on 18 Feb 2016
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.
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!