Sunday, 14 April 2013

People Counting System using face detection Code





close all;
clear all;
clc;
rgbInputImage = imread('photo.jpg');
labInputImage = applycform(rgbInputImage,makecform('srgb2lab'));
Lbpdfhe = fcnBPDFHE(labInputImage(:,:,1));
labOutputImage = cat(3,Lbpdfhe,labInputImage(:,:,2),labInputImage(:,:,3));
rgbOutputImage = applycform(labOutputImage,makecform('lab2srgb'));
figure, imshow(rgbInputImage);
figure, imshow(rgbOutputImage);
img=rgbOutputImage;
final_image = zeros(size(img,1), size(img,2));
if(size(img, 3) > 1)
for i = 1:size(img,1)
for j = 1:size(img,2)
R = img(i,j,1);
G = img(i,j,2);
B = img(i,j,3);
if(R > 92 && G > 40 && B > 20)
v = [R,G,B];
if((max(v) - min(v)) > 15)
if(abs(R-G) > 15 && R > G && R > B)
final_image(i,j) = 1;
end
end
end
end
end
end
binaryImage=im2bw(final_image,0.6);
figure, imshow(binaryImage);
binaryImage = imfill(binaryImage, 'holes');
figure, imshow(binaryImage);
binaryImage = bwareaopen(binaryImage,1890);
figure,imshow(binaryImage);
labeledImage = bwlabel(binaryImage, 8);
blobMeasurements = regionprops(labeledImage, final_image, 'all');
numberOfPeople = size(blobMeasurements, 1)
imagesc(rgbInputImage); title('Outlines, from bwboundaries()');
hold on;
boundaries = bwboundaries(binaryImage);
for k = 1 : numberOfPeople
thisBoundary = boundaries{k};
plot(thisBoundary(:,2), thisBoundary(:,1), 'g', 'LineWidth', 2);
end
imagesc(rgbInputImage);
hold on;
title('Original with bounding boxes');
for k = 1 : numberOfPeople
thisBlobsBox = blobMeasurements(k).BoundingBox;
x1 = thisBlobsBox(1);
y1 = thisBlobsBox(2);
x2 = x1 + thisBlobsBox(3);
y2 = y1 + thisBlobsBox(4);
x = [x1 x2 x2 x1 x1];
y = [y1 y1 y2 y2 y1];
plot(x, y, 'LineWidth', 2);
end                          


fcnBPDFHE() function should be added

avialable in mathworks website link is here :



Used image URL : 








6 comments:

  1. its good.. can u help me to get a code for to wavelet transform for oct images plzzz....

    ReplyDelete
  2. That's really great ! Just let me simply say what a relief to uncover a person that genuinely understands what they are talking about online. You certainly understand how to bring a problem to light and make it important. Thanks for sharing !

    ReplyDelete
  3. This is really interesting of implementing people counting using face detection. Would like to know more details about this in the further blogs. Delopt

    ReplyDelete
  4. hi, when i am running this code i am getting this error

    Error in ==> CODE1 at 6
    Lbpdfhe = fcnBPDFHE(labInputImage(:,:,1));


    please reslove my problem......

    ReplyDelete
  5. Sir please send me full code of face detection ..
    inan.akmaz@yandex.com

    ReplyDelete