Sunday, 1 September 2013

MATLAB CODE FOR SKINDETECTION IN HSV COLORS PACE

%detecting skin in hsv color space
clear all;
clc;

img=imread('family.jpg');

hsv=rgb2hsv(img);
out=hsv;
h=hsv(:,:,1);
s=hsv(:,:,2);
v=hsv(:,:,3);

%............................................................................
%for h component
%[row col v]=find(h>=0 & h<=0.25);
%num=size(row,1);
%for i=1:num
%    h(row(i),col(i))=1;
%end

%for s component
%[row col v]=find(s>0.15 & s<=0.9);
%num=size(row,1);
%for i=1:num
%    s(row(i),col(i))=0;
%end
%............................................................................



[row col v]=find( h>=0 & h<=0.25 & s>0.15 & s<=0.9);
num=size(row,1);

for i=1:num
    out(row(i),col(i),:)=0;
end
%imshow(out);

out_rgb=hsv2rgb(out);
imshow(out_rgb);

%dup(:,:,1)=h;
%dup(:,:,2)=s;
%dup(:,:,3)=v;

%dup_img=hsv2rgb(out);
%imshow(dup_img);



No comments:

Post a Comment