2017-02-21 65 views
-4

算法BLUE-白色的面纱DETECTION如何在MATLAB中为以下算法编写if-else条件语句?

**for** each pixel in extracted region do 
     **if** R > 90 and R > B and R > G then 
     Mark the pixel as **healthy skin**. 
     **else** 
     Ignore the pixel and continue. 
    **end if 
    end for** 
    Set R¯s as the mean of red channel values for pixels marked 
    healthy skin. 
    **for** each pixel in the image **do** 
     nB = B/R+G+B 
     rR = R/R¯s 
     **if** nB ≥ 0.3 and −194 ≤ rR < −51 then 
      Classify pixel as veil 
     **else** 
      Classify pixel as non-veil 
    **end if 
    end for** 

我已经执行的algorith即像素成健康皮肤或非健康的皮肤分类的第一部分。如何与第二部分相提并论?

clc; 
clear all; 
colorSkin=imread('veil.jpg'); %original image 
% colorSkin=imresize(a, [384 512]); 
[m, n]=size(colorSkin); 
hs = colorSkin; %initialising heaklthy skin array 
nhs = colorSkin; %initialising non-healthy skin array 
R = colorSkin(:, :, 1); 
G = colorSkin(:, :, 2); 
B = colorSkin(:, :, 3); 
ROI = R > 95 & R > B & R > G; 
ROI3 = ROI(:,:,[1 1 1]); 
hs(~ROI3) = 0; 
nhs(ROI3) = 0; 

当我尝试使用下面的命令来实现该算法的第二部分:

> nB=B(hs)./(R(hs)+B(hs)+G(hs)); 

我得到那个说错误“下标指标必须是真正的正整数或逻辑值。”

+3

您需要。 1)学习MATLAB。 2)参考以前的答案。这是我从你甚至没有接受的答案中得到的代码。 –

+2

[如何使用MATLAB从皮肤图像中提取蓝色遮罩特征]可能的重复(http://stackoverflow.com/questions/42352564/how-to-extract-the-blue-veil-feature-from-skin -images-in-using-matlab) – Adriaan

+2

请,我们需要您的最低质量的努力。阅读[问] –

回答

0

在你的算法中,你需要所有的所有数据,而不仅仅是健康的皮肤,至少你写它的方式它绝对看起来如此。否则,rR将是没有意义的。另外认识到你的伪代码必须是是错的,因为rR是不可能的。

Continuing from my previous answer

R=colorSkin(:, :, 1); 
G=colorSkin(:, :, 2); 
B=colorSkin(:, :, 3); 
skin=repmat(R>90 & R>B & R>G,1,1,3); 

hs=colorSkin; 
hs(~skin)=0; 
nhs(skin)=0; 

% new code 
nB = B./(R+G+B); % I assume you dont mean B./R+G+B as in the pseudocode.... 
rR=R./mean(R(skin(:,:,1)>0); 

% use the same code as before, changing the indexes to classify veil