From: wilson on
Image i get is from:
http://salmaworld.files.wordpress.com/2009/09/beautiful-face-wallpapers_11213_1280x1024.jpg
But i already crop it become small only can see the face.

I = imread('face 2.jpg');
[X Y] = size(I);
for i=1:X
for j = 1:Y/3

if (I(i,j,1)<90)&&(I(i,j,2)<80)&&(I(i,j,3)<100)

I(i,j,1)=1;
I(i,j,2)=1;
I(i,j,3)=1;
else
I(i,j,1)=255;
I(i,j,2)=255;
I(i,j,3)=255;
end
end
end
figure, imshow(I);
I = rgb2gray(I);

BW2 = edge(I,'canny',0.1);
figure, imshow(BW2);

From the above coding i already change it become binary! After that how am i gonna crop the eyes? So which point should i take as the 1st point and how am i gonna scan the picture through?
From: jrenfree on
On Nov 9, 2:57 pm, "wilson " <wilson_silver3...(a)hotmail.com> wrote:
> Image i get is from:http://salmaworld.files.wordpress.com/2009/09/beautiful-face-wallpape...
> But i already crop it become small only can see the face.
>
> I = imread('face 2.jpg');
> [X Y] = size(I);
> for i=1:X
>     for j = 1:Y/3
>
>         if (I(i,j,1)<90)&&(I(i,j,2)<80)&&(I(i,j,3)<100)
>
>             I(i,j,1)=1;
>              I(i,j,2)=1;
>               I(i,j,3)=1;
>         else
>              I(i,j,1)=255;
>              I(i,j,2)=255;
>               I(i,j,3)=255;
>         end
>     end
> end
> figure, imshow(I);
> I = rgb2gray(I);
>
> BW2 = edge(I,'canny',0.1);
> figure, imshow(BW2);
>
> From the above coding i already change it become binary! After that how am i gonna crop the eyes? So which point should i take as the 1st point and how am i gonna scan the picture through?

Not quite sure what the question is
From: ImageAnalyst on
Hmmmm..... Not sure where you're going with that. Why don't you see
how I find the eyes on your face image? Maybe you'll like my way
better. It works with your test image but it's not super robust.
Basically it finds the two largest dark blobs in the face as
determined by the thresholds you gave. Given more time I'd make it
better and more robust, but like I said, it does work fine with this
one image, and may work on others too.
Regards,
ImageAnalyst

Just copy, paste, fix lines broken into two by the newsreader
(IMPORTANT!), and run.

% Demo to find eyes in a face image.
% by ImageAnalyst
% function test
clc;
close all;
clear all;
workspace; % Show the Workspace panel.

% % Read in color image.
rgbImage = imread('face2.jpg');
[rows columns, numberOfColorPlanes] = size(rgbImage);
subplot(2,3,1);
imshow(rgbImage);
title('Color Image');
set(gcf, 'Position', get(0, 'ScreenSize')); % Maximize figure.
redPlane = rgbImage(:,:, 1);
greenPlane = rgbImage(:,:, 2);
bluePlane = rgbImage(:,:, 3);
redThreshold = 90;
greenThreshold = 80;
blueThreshold = 100;
binaryImage = (redPlane < redThreshold) & (greenPlane <
greenThreshold) & (bluePlane < blueThreshold);
binaryImage = ~binaryImage;
subplot(2,3,2);
imshow(binaryImage, []);
title('Color Segmented / Binary Image');
labeledImage = bwlabel(binaryImage);
blobMeasurements = regionprops(labeledImage, 'all');
numberOfBlobs = length(blobMeasurements);
maxArea = -1;
indexForMaxArea = 1;
for k = 1 : numberOfBlobs % Loop through all blobs.
% Find the mean of each blob. (R2008a has a better way where you can
pass the original image
% directly into regionprops. The way below works for all versions
including earlier versions.)
thisBlobsPixels = blobMeasurements(k).PixelIdxList; % Get list of
pixels in current blob.

blobArea = blobMeasurements(k).Area; % Get area.
if blobArea > maxArea
maxArea = blobArea;
indexForMaxArea = k;
biggestBlobPixels = thisBlobsPixels;
end
end
% Get an image with just the largest blob
faceImage = zeros(rows, columns);
faceImage(biggestBlobPixels) = 1;
subplot(2,3,3);
imshow(faceImage, []);
title('The Face');

% Do a fill to get the face without the eyes and mouth.
filledImage = imfill(faceImage, 'holes');

% Find just the eyes and mouth
eyesImage = ~faceImage .* filledImage;
subplot(2,3,4);
imshow(eyesImage, []);
title('Only the eyes and mouth');

% Do a closing to connect pixels in eye and mouth area.
closedImage = imclose(eyesImage, ones(5));
subplot(2,3,5);
imshow(closedImage, []);
title('eyes and mouth');

% Keep just the blobs bigger than 100.
eyesOnlyImage = bwareaopen(closedImage, 500);
subplot(2,3,6);
imshow(eyesOnlyImage, []);
title('Eyes only');

% Label this image.
labeledImage2 = bwlabel(eyesOnlyImage);
% Find the bounding box of the eyes.
blobMeasurements2 = regionprops(labeledImage2, 'BoundingBox');
numberOfBlobs = length(blobMeasurements2);
% Plot the bounding box of the eyes over the original image.
subplot(2,3,1);
hold on; % Don't let image get blown away by the plotting of the box.
for k = 1 : numberOfBlobs % Loop through all blobs.
blobBoundingBox = blobMeasurements2(k).BoundingBox; % Get centroid.
% Crop out this blob.
row1 = blobBoundingBox(2);
col1 = blobBoundingBox(1);
row2 = row1 + blobBoundingBox(4) - 1;
col2 = col1 + blobBoundingBox(3) - 1;
% Get the box (x,y) coordinates.
x = [col1 col2 col2 col1 col1];
y = [row1 row1 row2 row2 row1];
plot(x,y, 'r', 'LineWidth', 2);
end

msgbox('Done!');

From: wilson on
ImageAnalyst you are really professional in Matlab i gonna go through it and understand what are u doing! Give me sometime to understand ur coding coz i am just a beginner so i need to do lots of research in order to understand what going on! Can i get ur email add(if u prefer that u can email me ur address) that easy for me to contact u or u prefer me to post in here?
Cheers
From: ImageAnalyst on
On Nov 10, 9:08 pm, "wilson " <wilson_silver3...(a)hotmail.com> wrote:
> ImageAnalyst you are really professional in Matlab i gonna go through it and understand what are u doing! Give me sometime to understand ur coding coz i am just a beginner so i need to do lots of research in order to understand what going on! Can i get ur email add(if u prefer that u can email me ur address) that easy for me to contact u or u prefer me to post in here?
> Cheers

---------------------------------------------------------------------------------------------
Just post here. I don't monitor that email address and I can't even
reply from that email address.