lundi 20 février 2017

how to write this if else condition statement in MATLAB?

for each pixel, do
      if R>90 & R>G & R>B 
         classify the pixel as **Healthy**
      else 
         classify the pixel as non-healthy 

I am trying to implement an algorithm which reads a skin lesion image and after extracting the R, G, and B values, it classifies the lesion into healthy skin or non-healthy skin based on the if condition

However, when I try to implement it, only the non-healthy skin array is getting updated inside the for loop and the healthy skin array remains zero. I do not know how to overcome this glitch. Please help.

hs=zeros(m,n); %initialising healthy skin array
nhs=0;         %initialising non-healthy skin array 
R=colorSkin(:, :, 1);
G=colorSkin(:, :, 2);
B=colorSkin(:, :, 3);
for i = 1:m
    for j = 1:n     
        if R>90&R>B&R>G
            hs(i, j)= colorSkin(i, j);
        else
            nhs(i,j)=colorSkin(i,j);
        end
    end
end

Aucun commentaire:

Enregistrer un commentaire