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

조회 수: 3 (최근 30일)
Zun Sid
Zun Sid 2018년 6월 25일
답변: Nathan Jessurun 2019년 4월 14일
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