Why do I get an error when converting my MATLAB code (which utilizes "bwlabel") to C code using MATLAB Coder?
1 view (last 30 days)
Show older comments
MathWorks Support Team
on 7 Sep 2018
Edited: MathWorks Support Team
on 16 May 2019
I am trying to generate C/C++ code from my MATLAB program, which utilizes "bwlabel".
However, I encounter the following error message:
??? Computed maximum size of output #1 of function 'intermediateLabelRuns' is not bounded.
Static memory allocation requires all sizes to be bounded.
The computed size is [:? x 1].
Please consider enabling dynamic memory allocation to allow unbounded sizes.
Here is an excerpt of my example code:
im_bin = zeros(dim_X,dim_Y);
coder.varsize('im_bin');
for idx=1:dim_X
for idy = 1:dim_Y
if (im(idx,idy) < threshold)
im_bin(idx,idy) = 0;
else
im_bin(idx,idy) = 1;
end
end
end
[label, nblabel] = bwlabel(im_bin, 4);
Accepted Answer
MathWorks Support Team
on 16 May 2019
Edited: MathWorks Support Team
on 16 May 2019
A possible cause of this error message Dynamic Memory Allocation During Code Generation is disabled. Please check the coder configuration to see if something similar to the following segment exists:
cfg = coder.config();
cfg.DynamicMemoryAllocation = 'Off';
codegen -config cfg ...
Replacing "Off" with one of the other choices for "DynamicMemoryAllocation" will avoid the issue.
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!