clc; clear all; img_orig = imread('sss2.

jpg'); height = size(img_orig,1); width = size(img_orig,2); %Initialize the output images out = img_orig; bin = zeros(height,width);%initialize bin %Convert the image from RGB to YCbCr img_ycbcr = rgb2ycbcr(img_orig); Cb = img_ycbcr(:,:,2); Cr = img_ycbcr(:,:,3); %Detect Skin [r,c,v] = find(Cb>=77 & Cb<=127 & Cr>=133 & Cr<=173); numind = size(r,1); %Skin Pixels for i=1:numind out(r(i),c(i),:) = [0 0 255]; bin(r(i),c(i)) = 1; bin2=bin.*2;% scaling factor end imshow(img_orig); figure; imshow(out); figure; imshow(bin); figure; imshow(bin2); obj = bwareaopen(bin,800);% Remove all objects in the image containing fewer th an 800 pixels cc = bwconncomp(obj,8);% connectivity set more closer imshow(obj); data = regionprops(cc,'basic'); for i=1:9 p=data(i).Centroid; % faces=centroids disp(p); end

Sign up to vote on this title
UsefulNot useful