Clear Filters
Clear Filters

Info

This question is closed. Reopen it to edit or answer.

error in if cicle due to grayscale images and binary images

1 view (last 30 days)
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 Comment
Rik
Rik on 20 Jun 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.

Answers (0)

This question is closed.

Community Treasure Hunt

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

Start Hunting!