Bwconncomp code conversion in c++ using matlab coder gives error

3 次查看(过去 30 天)
Bwconncomp returns a variable with 4 fields. one of them is pixelIdxlist which is of type cell array. For code conversion, We have to allocate the memory to variable beforehand. While allocating memory, Matlab coder gives an error "Code generation does not support cell arrays in structure fields.","This structure does not have a field 'PixelIdxList'." How can I resolve these errors. Here's my code:
n=14456;
A = ones(1,n);
sz = size(A);
p = cell(sz);
field6='PixelIdxList'; value6 ={p};
CC = struct(field3,value3,field4,value4,field5,value5,field6, value6 );
CC = bwconncomp(I3);
A=NaN(9999,1);
for i = 1:size(CC.PixelIdxList,2)
A(i) = size(CC.PixelIdxList{i},1);
end
[Val,Idx] = max(A);
L = zeros(CC.ImageSize);
for k = 1 : CC.NumObjects
L(CC.PixelIdxList{k}) = k;
end
L(find(L~=Idx))=0;
L(find(L==Idx))=1;
%continue....

回答(1 个)

Nathan Jessurun
Nathan Jessurun 2019-4-14
From the bwconncomp help page (here), they make the statement under C++ code generation:
The PixelIdxList field in the CC struct return value is not supported.
So it looks like what you're doing isn't possible yet.

类别

Help CenterFile Exchange 中查找有关 MATLAB Coder 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by