1、图像分割
2、获取样本
3、样本学习
4、模式分类
(1)最小误判概率准则
(2)最小风险准则
org = imread('1.jpg');
HSI=rgb2hsi(org);
%可以通过下面的程序看一幅图的HSV三个通道
H=HSI(:,:,1);
S=HSI(:,:,2);
I=HSI(:,:,3);
figure(1);
subplot(2,2,1);imshow(org);title('(1)原始图像','color','b');
% % figure(1);
% subplot(2,3,1),imshow(rgb),title(' 原图');
% subplot(2,3,2),imshow(H),title('色度图H ');
% subplot(2,3,3),imshow(S),title('饱和度图S');
% subplot(2,3,4),imshow(I),title(' 强度图I');
subplot(2,2,2);imhist(H);title('(2)H分量直方图','color','b');
subplot(2,2,3);imhist(S);title('(3)S分量直方图','color','b');
subplot(2,2,4);imhist(I);title('(4)I分量直方图','color','b');
thresh = graythresh(H);
hh = im2bw(H,thresh);
figure(3);
imshow(hh);title(' H分量');
M=~hh;
figure(2);
imshow(M);title(' H分量的二值化图');
[m n]=size(H);
a1 = numel(M,M>0.5);
a2 = numel(M,M<0.5);
PW1 = a1/(m*n);
PW2 = a2/(m*n);
threa=PW2/PW1;
threa1=PW2/(10*PW1)
PW1_x = H.*M;
PW2_x = H.*hh;
figure(4);
subplot(1,2,1);imhist(PW1_x);title('(1)皮肤H分量直方图','color','b');
subplot(1,2,2);imhist(PW2_x);title('(2)非皮肤H分量直方图','color','b');
pp=reshape(PW1_x,1,256*256)
PP=pp;
PW1_x(PW1_x==0)=inf;
sApProMax=max(pp);
sApProMin=min(min(PW1_x));
x=linspace(sApProMin,sApProMax,8);
yy=hist(pp,x);
yy1=yy/length(pp);
figure(5);
title(' 皮肤的类条件概率密度');
a=[1:8];
bar(a,yy1);
%fei pifu
pp2=reshape(PW2_x,1,256*256)
PW2_x(PW2_x==0)=inf;
sApProMax2=max(pp2);
sApProMin2=min(min(PW2_x));
x2=linspace(sApProMin2,sApProMax2,8);
yy2=hist(pp2,x2);
yy12=yy2/length(pp2);
figure(6);
title(' 非皮肤的类条件概率密度');
bar(a,yy12);
x3=linspace(sApProMin,sApProMax,9);
for i=1:8
l12 = yy1(i)/yy12(i);
if l12>threa
for j=1:256*256;
if PP(j)<x3(i+1)&&PP(j)>x3(i);
PP(j)=1;
end
end
else
for z=1:256*256;
if PP(z)<x3(i+1)&&PP(z)>x3(i);
PP(j)=0;
end
end
end
end
New=reshape(PP,256,256);
figure(7);
imshow(New);
d=double(org);
r=d(:,:,1).*New;
g=d(:,:,2).*New;
b=d(:,:,3).*New;
rgb(:,:,1)=r;
rgb(:,:,2)=g;
rgb(:,:,3)=b;
rgb8=uint8(rgb);
figure(8);
imshow(rgb8);
for i=1:8
l12 = yy1(i)/yy12(i);
if l12>threa1
for j=1:256*256;
if PP(j)<x3(i+1)&&PP(j)>x3(i);
PP(j)=1;
end
end
else
for z=1:256*256;
if PP(z)<x3(i+1)&&PP(z)>x3(i);
PP(j)=0;
end
end
end
end
New1=reshape(PP,256,256);
figure(7);
imshow(New1);
d=double(org);
r=d(:,:,1).*New1;
g=d(:,:,2).*New1;
b=d(:,:,3).*New1;
rgb(:,:,1)=r;
rgb(:,:,2)=g;
rgb(:,:,3)=b;
rgb8=uint8(rgb);
figure(9);
imshow(rgb8);
181

被折叠的 条评论
为什么被折叠?



