I have to remove small objects from binary image and Im trying to use bwareaopen in simulink by using following code:
function y = fcn(u)
x = zeros(size(u));
coder.extrinsic('bwareaopen');
x = bwareaopen(u, 50);
y = double(x);
and getting error:
Class mismatch for variable 'bwareaopen'. Expected 'double', Actual 'logical'. Block MATLAB Function (#24) While executing: none
Model is as follows:
%

 채택된 답변

Ryan Livingston
Ryan Livingston 2014년 4월 2일

0 개 추천

For allocating logical data use either of the functions true or false:
x = true(size(u));
x = false(size(u));

댓글 수: 5

Nazim Badar
Nazim Badar 2014년 4월 7일
Thanks 4 your support.... Its working Now.
I have done the same thing but getting an error. I am using matlab2016a.
"The extrinsic function 'xor' is not available for standalone code generation. It must be eliminated for stand-alone code to be generated. It could not be eliminated because its outputs appear to influence the calling function. Fix this error by not using 'xor' or by ensuring that its outputs are unused."
"The extrinsic function 'bwareaopen' is not available for standalone code generation. It must be eliminated for stand-alone code to be generated. It could not be eliminated because its outputs appear to influence the calling function. Fix this error by not using 'bwareaopen' or by ensuring that its outputs are unused."
this is my code:
function y = fcn(u)
coder.extrinsic('bwareaopen');
coder.extrinsic('xor');
noSmallStructure = false(size(u));
noSmallStructure = xor(bwareaopen(u, 15),bwareaopen(u, 862));;
y = double(noSmallStructure);
end
i really need help to get rid of this errors. Thanks in advance
%
Walter Roberson
Walter Roberson 2016년 5월 18일
편집: Walter Roberson 2016년 5월 18일
xor can be replaced by ~=
In R2016a bwareaopen is supported for code generation, but there is a notation about "MATLAB Function Block support: No". I am not sure what that implies at the moment. It might mean that it is supported by MATLAB Coder but not by Simulink Coder -- since Simulink Coder is for deploying to targets, there could be a difference in support.
Sayed Rizban Hussain
Sayed Rizban Hussain 2016년 5월 18일
편집: Sayed Rizban Hussain 2016년 5월 18일
yes bwareaopen is supported in matlab coder as I have used it previously. Now my target machine is raspberry pi. Can you suggest me any function that can replace bwareaopen? As for my application I only need objects of a specific area range.
bwlabel and count the number of matches of each label?

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Kaustubha Govind
Kaustubha Govind 2014년 3월 20일

0 개 추천

It looks like bwareaopen returns an output of type logical. You need to pre-declare 'x' as follows:
x = zeros(size(u), 'logical');

댓글 수: 1

Nazim Badar
Nazim Badar 2014년 3월 22일
편집: Nazim Badar 2014년 3월 22일
Thanks Kaustubha for your response, I tried declaring as you suggested but get following error:
Invalid value 'logical' for the trailing string argument. This argument must be a valid numeric class name: 'double', 'single', 'int8', 'uint8', 'int16', 'uint16', 'int32', or 'uint32'.
Function 'MATLAB Function' (#34.34.58), line 3, column 5:
"zeros(size(u),'logical')"
Launch diagnostic report.
Still not able to declare correctly.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Computer Vision with Simulink에 대해 자세히 알아보기

질문:

2014년 3월 20일

댓글:

2016년 5월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by