Borrar filtros
Borrar filtros

How use if else statement for floating point number

2 visualizaciones (últimos 30 días)
Quah Yi Hang
Quah Yi Hang el 18 de Mzo. de 2022
Editada: Quah Yi Hang el 18 de Mzo. de 2022
the total of white pixels are found as floating point number. I want to do something when the total white pixels exceed 4000, else do nothing.
But my code can't work. Can anyone help me?
BW2 is my binary image
numWhitePixels = sum(BW2(:));
fprintf('%f\n',numWhitePixels)
if numWhitePixels >= 4000
se90 = strel('line',3,90);
se0 = strel('line',3,0);
BWsdil = imdilate(BW2,[se90 se0]);
BW3 = imfill(BWsdil, 'holes');
figure
imshow(BW3)
impixelinfo;
else
figure
imshow(BW2);
end
  2 comentarios
Walter Roberson
Walter Roberson el 18 de Mzo. de 2022
What value is getting printed out by the fprintf when you run the code?
Quah Yi Hang
Quah Yi Hang el 18 de Mzo. de 2022
Editada: Quah Yi Hang el 18 de Mzo. de 2022
ops, is my mistake, i set wrong number in the if statement
sorry about that.
thank for remind me

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Images 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