Effacer les filtres
Effacer les filtres

Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

error in if cicle due to grayscale images and binary images

1 vue (au cours des 30 derniers jours)
sofia cirne
sofia cirne le 20 Juin 2017
Clôturé : MATLAB Answer Bot le 20 Août 2021
im trying to calculate porosity throgh a funtion (bellow), either from a binary image or a grayscale image in one pusch button, but the grayscale image is not able to calculate, it just give another value, incorrect. the binary works fine. a = handles.grey; b = handles.imgData; B = im2double(b); A = im2double(a); I = handles.binaria;
[r c d]=size(a)
if d == 0 % black pixels c = sum(sum(A == 0));
textLabel2 = sprintf('%d', c); set(handles.areaporos, 'String', textLabel2);
% total pixels numPixels = numel(B); textLabel = sprintf('%d', numPixels); set(handles.areatotal, 'String', textLabel);
%porosidade P = ((c/numPixels)*100); textLabe4 = sprintf('%d', P); set(handles.porosidade, 'String', textLabe4);
else
h = sum(sum(I == 0)); textLabel5 = sprintf('%d', h); set(handles.areaporos, 'String', textLabel5);
numPixels = numel(B); textLabel = sprintf('%d', numPixels); set(handles.areatotal, 'String', textLabel);
H = ((h/numPixels)*100); textLabe6 = sprintf('%d', H); set(handles.porosidade, 'String', textLabe6); end end
  1 commentaire
Rik
Rik le 20 Juin 2017
Your code is unreadable, you give no example data, you don't say what the output should be. Have a read here and here. It will greatly improve your chances of getting an answer.

Réponses (0)

Cette question est clôturée.

Community Treasure Hunt

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

Start Hunting!

Translated by