Azzera filtri
Azzera filtri

bwconncomp and conn=3-by-3 constant marix not working for C/C++ Code Generation, despite using R2023b

16 visualizzazioni (ultimi 30 giorni)
Hello,
I want to use bwconncomp with 2D binary images and pure column-wise connectivity for code generation, and was delighted to read in the documentation, that since MATLAB R2023a the limitation for conn=4 and conn=8 is supposed to be over:
R2023a: Additional support for C code generation
You can now generate C code for input images of any dimension. Before, bwconncomp supported code generation only for 2-D inputs. Also, you can now specify any connectivity that is a compile-time constant. Before, bwconncomp supported code generation only for connectivities of 4, 8, [0 1 0;1 1 1;0 1 0], or ones(3)
However, this line just does not want to pass in the coder
CC = bwconncomp(BW,[0 1 0;0 1 0;0 1 0]);
and always produces an error "bwconncomp>3, Line 25: Expected a scalar. Non-scalars are not supported with logical operators...."
despite using MATLAB version R2023b, where as
CC = bwconncomp(BW,[0 1 0;1 1 1;0 1 0]);
just compiles fine (which actually is conn=4). Why is that, if it is supposed to work now for any 3-by-3 connectivities, as alleged in the documentation ?
Thanks

Risposte (1)

Githin George
Githin George il 6 Feb 2024
Hello Robin,
I've attempted to generate C code for the "bwconncomp" function using the "conn" matrix you have provided, but I'm encountering the same error message. Upon examining the "bwconncomp.m" file, I noticed that the error is triggered by a validation check on the "conn" matrix (refer to Line: 25 in bwconncomp.m). The underlying issue is that the "conn" matrix is treated as a compile-time constant, which is essentially a “coder.Constant” object. The validation uses an “ismember” check, which passes for a "double" matrix but fails for compile-time constants. In the scenario where conn = [0 1 0; 1 1 1; 0 1 0], it gets automatically converted to “conn = 4”. This conversion allows code generation to complete successfully.
For further information on the “coder.Constant” class and "ismember" function, please refer to the documentation links below:
Given that the error originates from a toolbox file, I recommend that you contact the MathWorks Technical Support team for additional support. You can reach out to them using the following link:
I hope this information is helpful to you.

Categorie

Scopri di più su MATLAB Coder in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by