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
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!');
---------------------------------------------------------------------------------------------
Just post here. I don't monitor that email address and I can't even
reply from that email address.
--------------------------------------------------------------------------------------
You may have to tweak the algorithm. It may only work in some set of
situations. For example a certain magnification and pose. For
example if someone has one eye open, one eye closed, and their mouth
open, that algorithm may think the open mouth is the other eye. Or if
the person is so far away that the eyes are only a few pixels then it
may have problems. Or if their eyes are closed and the camera is
looking up their nostrils then it will pick the nostrils as the eyes.
What if you have a picture of a yellow smiley face? Do you want to
define its "eyes" as real eyes, or reject them because they're not
from a real live human? It can get pretty tricky. That's why I said
it's not robust. The better able you are to control your subject, the
easier it will be.
-------------------------------------------------------------------
The method I sketched out should work reasonably well if all your
pictures are similar to the test photo you provided. That is, a face
taking up most of the picture, eyes both open, mouth closed, etc.
--------------------------------------
Didn't I just answer that in
http://groups.google.com/group/comp.soft-sys.matlab/browse_frm/thread/d8a262543c9902d4/92fafcf481a44cc2?hl=en#92fafcf481a44cc2
Are you the same person as "boy boy"? I think so.
Please don't have separate threads going on the very same question.
---------------------------------------------
Good luck with that.
I thought what are the chances that two totally unrelated people would
choose to use the very same face on the very same obscure web site for
your explorations? One in 10 billion???? Apparently you say you did
- what a remarkable coincidence! Maybe you should start buying
lottery tickets.
Somebody else here is interested in working with people on iris
matching - search the newsgroup:
http://groups.google.com/group/comp.soft-sys.matlab/search?hl=en&q=iris&start=0&hl=en&
I'm sure Nicolaie Popescu-Bodorin would be delighted to hear from you.
I suggest you use the Hough transform as in this demo:
http://hci.iwr.uni-heidelberg.de/mip_teaching/ip/solution06/solution6.html
croppedImage = fullImage(row1:row2, column1:column2);
Of course you need to figure out what row1, row2, column1, and column2
are based on your algorithm.
----------------------------
Um, that is the bounding box of your iris - we've talked about this
already.
----------------------------------------------------------------------------------
Allright. I simply just added that line to my previous code (look way
down near the very end of the code):
Again, fix the line breaks introduced by the newsreader:
% function test
% 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('C:\Documents and Settings\tk2013\My Documents
\Temporary stuff\face2.jpg');
[rows columns, numberOfColorPlanes] = size(rgbImage);
subplot(3, 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(3, 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(3, 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(3, 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(3, 3,5);
imshow(closedImage, []);
title('eyes and mouth');
% Keep just the blobs bigger than 100.
eyesOnlyImage = bwareaopen(closedImage, 500);
subplot(3, 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.
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];
subplot(3, 3,1);
hold on; % Don't let image get blown away by the plotting of the
box.
plot(x,y, 'r', 'LineWidth', 2);
% Crop the eye and put it in a new image
croppedImage = rgbImage(row1:row2, col1:col2, :);
subplot(3, 3, k + 6);
imshow(croppedImage);
end
msgbox('Done!');
------------------------------------------------------
The final : means to take all 3 color bands. Recall that : in MATLAB
basically means "all" when it's used alone as in this case. rgbImage
is a 3 color image, thus croppedImage will also be a 3 color image
because I used the :.
--------------------------------------------------------------------
I don't know, but I'm sure you can experiment around with it just as
I'd have to.
szImg1 = size(eyes);
rad1ct = 600; % radii to be searched (in pixels)
gradthr = 0.15;
%opt = 'prop';
[haa1ct,grad] = cht(eyes,rad1ct,gradthr);
figure; imagesc(grad); axis equal tight off; colormap gray;
title('Edge strengths from Sobel filtering');
figure; imagesc(haa1ct); axis equal tight off; colormap gray;
title('Circle Hough transform with a radius of 600 pixels (proportional)');
its appear error on that [haa1ct,grad] = cht(eyes,rad1ct,gradthr);
Hey m just a beginner in matlab image scanning.. m doing a project in that...can u plz tell why u ran d second loop till y/3......is it bcoz of the size of the face....what if we dont know what the image is gonna be....>???