蓝白检测的算法
**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**
我已经执行了算法的第一部分,即将像素分类为健康皮肤或非健康皮肤。如何与第二部分一起进行?
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));
我收到的错误是“下标索引必须是正整数或逻辑。”
答案 0 :(得分:0)
在你的算法中,你需要RBG 所有数据,而不仅仅是健康的皮肤,至少你写它的方式肯定是这样。否则,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