Algorithm 如何在MATLAB中为以下算法编写if else条件语句?

Algorithm 如何在MATLAB中为以下算法编写if else条件语句?,algorithm,matlab,image-processing,Algorithm,Matlab,Image Processing,蓝白面纱检测算法 **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 m

蓝白面纱检测算法

**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**
当我尝试使用以下命令实现算法的第二部分时:

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

我得到一个错误,它说“下标索引必须是实正整数或逻辑数。”

在你的算法中,你需要所有数据的RBG,而不仅仅是健康的皮肤,至少你写它的方式看起来确实如此。否则,
rR
就没有意义了。另外要意识到伪代码一定是错误的,因为
rR
不可能是负数


你需要这样做。1) 学习MATLAB。2) 参考以前的答案。这是我的代码,你甚至没有接受。可能重复的请,我们需要你的最低质量的努力。我对此感到抱歉。我对MATLAB和stackoverflow都是新手。下次发帖之前,我会先读一读“如何提问”。谢谢你的耐心和帮助,
> nB=B(hs)./(R(hs)+B(hs)+G(hs));
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