I am not getting proper output for the following skin detection program.Where am I wrong??
Show older comments
I am doing Face detction using skin color segmentation.

For this image,No output is shown for figure 4 and figure 5

For this Image,the same type of error occurs.

For this totally different output is showing
This is the program I used.
clc;
clear all;
currentimg=imread('Bush.jpg'); %capture the image of interest
figure(1)
subplot(421);
imshow(currentimg);
%Read the image, and capture the dimensions
VidImage = currentimg;
height = size(VidImage,1);
width = size(VidImage,2);
%Initialize the output images
out = VidImage;
bin = zeros(height,width);
%Convert the image from RGB to YCbCr
img_ycbcr = rgb2ycbcr(VidImage);
Cb = img_ycbcr(:,:,2);
Cr = img_ycbcr(:,:,3);
subplot(422);
imshow(img_ycbcr);
%Detect Skin
[r,c,v] = find(Cb>=77 & Cb<=127 & Cr>=133 & Cr<=173);
numind = size(r,1);
%Mark Skin Pixels
for i=1:numind
out(r(i),c(i),:) = [0 0 255];
bin(r(i),c(i)) = 1;
end
binaryImage=im2bw(bin,graythresh(bin));
binaryImage=~binaryImage;
subplot(423);
imshow(binaryImage);
B = bwboundaries(binaryImage);
disp(B);
binaryImage = imfill(binaryImage,'holes');
subplot(424);
imshow(binaryImage);
% Remove tiny regions.
binaryImage = bwareaopen(binaryImage, 5000);
subplot(425);
imshow(binaryImage);
%---------------------------------------------------------------------------
% Extract the largest area using ImageAnalyst's custom function
ExtractNLargestBlobs().
biggestBlob = ExtractNLargestBlobs(binaryImage, 1);
% Display the image.
subplot(426)
imshow(biggestBlob, []);
title('Final Image');
%--------------------------------------------------------------------------
[labeledImage, numberOfBlobs] = bwlabel(biggestBlob, 8);
% Get all the blob properties.
blobMeasurements = regionprops(labeledImage, 'BoundingBox','Area');
allBlobAreas = [blobMeasurements.Area];
% Display the original gray scale image.
subplot(427);
imshow(currentimg, []);
% Loop through all blobs, putting up Bounding Box.
hold on; % Prevent boxes from blowing away the image and prior boxes.
for k = 1 : numberOfBlobs
boundingBox = blobMeasurements(k).BoundingBox; % Get box.
x1 = boundingBox(1);
y1 = boundingBox(2);
x2 = x1 + boundingBox(3) - 1;
y2 = y1 + boundingBox(4) - 1;
verticesX = [x1 x2 x2 x1 x1];
verticesY = [y1 y1 y2 y2 y1];
plot(verticesX, verticesY);
end
4 Comments
yonatan gerufi
on 7 Sep 2014
please edit your post,
the code is not readable,
use the preview session beneath your edit area.
dpb
on 7 Sep 2014
Insert 2 blanks before the first character in the first line of code and then eliminate the spaces between...the two blanks on line turn it to the coding format...
Image Analyst
on 7 Sep 2014
Edited: Image Analyst
on 7 Sep 2014
http://www.mathworks.com/matlabcentral/answers/13205-tutorial-how-to-format-your-question-with-markup. I see that after your edit, you still couldn't figure out how to format, so I did it for you (this time).
Dhivakar Babu
on 7 Sep 2014
Accepted Answer
More Answers (0)
Categories
Find more on Images in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

