필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

error in if cicle due to grayscale images and binary images

조회 수: 1 (최근 30일)
sofia cirne
sofia cirne 2017년 6월 20일
마감: MATLAB Answer Bot 2021년 8월 20일
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
Rik
Rik 2017년 6월 20일
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.

답변 (0개)

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by