How to convert mxarray datatype in simulink

6 visualizaciones (últimos 30 días)
Nazim Badar
Nazim Badar el 20 de Mzo. de 2014
Comentada: Walter Roberson el 18 de Mayo de 2016
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:
%

Respuesta aceptada

Ryan Livingston
Ryan Livingston el 2 de Abr. de 2014
For allocating logical data use either of the functions true or false:
x = true(size(u));
x = false(size(u));
  5 comentarios
Sayed Rizban Hussain
Sayed Rizban Hussain el 18 de Mayo de 2016
Editada: Sayed Rizban Hussain el 18 de Mayo de 2016
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.
Walter Roberson
Walter Roberson el 18 de Mayo de 2016
bwlabel and count the number of matches of each label?

Iniciar sesión para comentar.

Más respuestas (1)

Kaustubha Govind
Kaustubha Govind el 20 de Mzo. de 2014
It looks like bwareaopen returns an output of type logical. You need to pre-declare 'x' as follows:
x = zeros(size(u), 'logical');
  1 comentario
Nazim Badar
Nazim Badar el 22 de Mzo. de 2014
Editada: Nazim Badar el 22 de Mzo. de 2014
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.

Iniciar sesión para comentar.

Categorías

Más información sobre Computer Vision with Simulink en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by