Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Pixel Scan

1 view
Skip to first unread message

wilson

unread,
Nov 9, 2009, 5:49:01 PM11/9/09
to
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?

wilson

unread,
Nov 9, 2009, 5:57:01 PM11/9/09
to

jrenfree

unread,
Nov 9, 2009, 7:53:58 PM11/9/09
to
On Nov 9, 2:57 pm, "wilson " <wilson_silver3...@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

ImageAnalyst

unread,
Nov 9, 2009, 9:16:21 PM11/9/09
to
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!');

wilson

unread,
Nov 10, 2009, 9:08:02 PM11/10/09
to
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

ImageAnalyst

unread,
Nov 10, 2009, 9:36:57 PM11/10/09
to
On Nov 10, 9:08 pm, "wilson " <wilson_silver3...@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.

guccikitty

unread,
Nov 10, 2009, 9:30:29 PM11/10/09
to
we are selling gucci shoes, gucci bags and ugg boots. welcome to join us. http://www.gucci-shoes-bags.com
http://www.uggbootshoes.com

wilson

unread,
Nov 12, 2009, 12:36:03 PM11/12/09
to
ImageAnalyst if i change to other picture what should i change in the coding?
Because the target seem to run to other place its wont exactly get the target u want?
So 1st izzit i need to fix some distance to take the picture so that everytime whenever i scan the face it will get the target exactly the eyes i wan?
Is that concept correct?

ImageAnalyst

unread,
Nov 12, 2009, 1:00:44 PM11/12/09
to

--------------------------------------------------------------------------------------
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.

wilson

unread,
Nov 12, 2009, 9:36:01 PM11/12/09
to
For my research is just concentrate on eyes, so i just can ignore the mouth part! I just need to take the eyes out from the face! The eyes for everyone is the same if i fix a distance example 1m within the camera then i can directly target the eye just like the method u teach me! But i gonna to make sure the eyes are both open in order to get the target. Because if i use manual cropping method it make my project become inapplicable so i need to think of something that can automatically crop the eye out once the target (eyes) match with the original image. Is this method applicable for my project?

ImageAnalyst

unread,
Nov 12, 2009, 10:07:41 PM11/12/09
to
On Nov 12, 9:36 pm, "wilson " <wilson_silver3...@hotmail.com> wrote:
> For my research is just concentrate on eyes, so i just can ignore the mouth part! I just need to take the eyes out from the face! The eyes for everyone is the same if i fix a distance example 1m within the camera then i can directly target the eye just like the method u teach me! But i gonna to make sure the  eyes are both open in order to get the target. Because if i use manual cropping method it make my project become inapplicable so i need to think of something that can automatically crop the eye out once the target (eyes) match with the original image. Is this method applicable for my project?

-------------------------------------------------------------------
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.

wilson

unread,
Nov 25, 2009, 7:05:21 PM11/25/09
to
ImageAnalyst: How can i crop the eye out from the image?
I dunno how to locate the location!

ImageAnalyst

unread,
Nov 29, 2009, 12:11:18 PM11/29/09
to
On Nov 25, 7:05 pm, "wilson " <wilson_silver3...@hotmail.com> wrote:
> ImageAnalyst: How can i crop the eye out from the image?
> I dunno how to locate the location!

--------------------------------------
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.

wilson

unread,
Nov 29, 2009, 1:28:01 PM11/29/09
to

Oh ok i got ur point i will try the crop method that u teach boy boy!
Sorry i am different person!

ImageAnalyst

unread,
Nov 29, 2009, 7:00:06 PM11/29/09
to
On Nov 29, 1:28 pm, "wilson " <wilson_silver3...@hotmail.com> wrote:
> Oh ok i got ur point i will try the crop method that u teach boy boy!
> Sorry i am different person!

---------------------------------------------
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.

wilson

unread,
Dec 3, 2009, 10:35:23 AM12/3/09
to
ImageAnalyst i got some difficulties problem now! Need some info from you!
Now how am i gonna extract my iris become like this link
http://www.merl.com/projects/images/irisrecognition.jpg
Make 2 circle on the iris how can i do it i had no idea on that can u teach me?

ImageAnalyst

unread,
Dec 3, 2009, 11:28:31 AM12/3/09
to
On Dec 3, 10:35 am, "wilson " <wilson_silver3...@hotmail.com> wrote:
> ImageAnalyst i got some difficulties problem now! Need some info from you!
> Now how am i gonna extract my iris become like this linkhttp://www.merl.com/projects/images/irisrecognition.jpg

> Make 2 circle on the iris how can i do it i had no idea on that can u teach me?
----------------------------------------------------------------------------------------------------------------------------------------------------------------------

I suggest you use the Hough transform as in this demo:
http://hci.iwr.uni-heidelberg.de/mip_teaching/ip/solution06/solution6.html

wilson

unread,
Dec 3, 2009, 12:31:30 PM12/3/09
to
Thanks ImageAnalyst i will try to work out of it! U do help me a lots!
Thanks for the hints Cheers!

wilson

unread,
Dec 3, 2009, 12:39:22 PM12/3/09
to
ImageAnalyst i still cant manage to crop out the rectangle from the target eye!
croppedImage = fullImage(x,y); i try using this to crop it but it come out error how can i do to crop it out automatically?

ImageAnalyst

unread,
Dec 3, 2009, 1:10:34 PM12/3/09
to
On Dec 3, 12:39 pm, "wilson " <wilson_silver3...@hotmail.com> wrote:
> ImageAnalyst i still cant manage to crop out the rectangle from the target eye!
> croppedImage = fullImage(x,y); i try using this to crop it but it come out error how can i do to crop it out automatically?
--------------------------------------------------------------------------------------------------------
That doesn't crop - that just takes the value of the single pixel at
location (x,y) and assigns it to croppedImage (which isn't actually an
image - it's just a pixel value). It should not have generated an
error though.
Do something like this (like I told boy boy in that other thread that
you said you were going to look at):

croppedImage = fullImage(row1:row2, column1:column2);

Of course you need to figure out what row1, row2, column1, and column2
are based on your algorithm.

wilson

unread,
Dec 3, 2009, 5:30:40 PM12/3/09
to
ImageAnalyst From the code above what is the figure number for row1, row2, col1 and col 2. still error i dunno why! Perhaps i put wrong figure!

ImageAnalyst

unread,
Dec 3, 2009, 5:35:33 PM12/3/09
to
On Dec 3, 5:30 pm, "wilson " <wilson_silver3...@hotmail.com> wrote:
> ImageAnalyst From the code above what is the figure number for row1, row2, col1 and col 2. still error i dunno why! Perhaps i put wrong figure!
> croppedImage = fullImage(row1:row2, column1:column2);

----------------------------
Um, that is the bounding box of your iris - we've talked about this
already.

wilson

unread,
Dec 3, 2009, 6:22:19 PM12/3/09
to
ImageAnalyst i can't get ur point. Can you show me how to crop the iris based on the code above? Sorry i am totally confuse now perhaps i am noob in Matlab!

ImageAnalyst

unread,
Dec 3, 2009, 10:35:05 PM12/3/09
to
On Dec 3, 6:22 pm, "wilson " <wilson_silver3...@hotmail.com> wrote:
> ImageAnalyst  i can't get ur point. Can you show me how to crop the iris based on the code above? Sorry i am totally confuse now perhaps i am noob in Matlab!

----------------------------------------------------------------------------------
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!');

wilson

unread,
Dec 4, 2009, 8:35:11 AM12/4/09
to
ImageAnalyst
> % Crop the eye and put it in a new image
> croppedImage = rgbImage(row1:row2, col1:col2, :);
row1:row2, col1:col2, then why need another :? can u explain for me?

ImageAnalyst

unread,
Dec 4, 2009, 8:46:16 AM12/4/09
to

------------------------------------------------------
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 :.

wilson

unread,
Dec 4, 2009, 11:01:09 PM12/4/09
to
Thanks now i understand it!
www.cl.cam.ac.uk/users/jgd1000/iriscode.gif
If i wanna do like the above link i need to use hough transform method?
or str8 away used neural network to do this? How to do the iris code on top of the left corner? How am i manage to do that?

ImageAnalyst

unread,
Dec 5, 2009, 7:31:47 AM12/5/09
to
On Dec 4, 11:01 pm, "wilson " <wilson_silver3...@hotmail.com> wrote:
> Thanks now i understand it!www.cl.cam.ac.uk/users/jgd1000/iriscode.gif

> If i wanna do like the above link i need to use hough transform method?
> or str8 away used neural network to do this? How to do the iris code on top of the left corner? How am i manage to do that?
----------------------------------------------------------------------------------------------------------------
Yes, I would look into the hough transform.

wilson

unread,
Dec 5, 2009, 10:05:03 AM12/5/09
to
ImageAnalyst <imagea...@mailinator.com> wrote in message <a0ed957f-04e4-4792...@o33g2000vbu.googlegroups.com>...

> On Dec 4, 11:01?pm, "wilson " <wilson_silver3...@hotmail.com> wrote:
> > Thanks now i understand it!www.cl.cam.ac.uk/users/jgd1000/iriscode.gif
ok if i use hough transform how am i do the iris code like above the left corner!

ImageAnalyst

unread,
Dec 5, 2009, 1:05:30 PM12/5/09
to
On Dec 5, 10:05 am, "wilson " <wilson_silver3...@hotmail.com> wrote:
> ok if i use hough transform how am i do the iris code like above the left corner!

--------------------------------------------------------------------
I don't know, but I'm sure you can experiment around with it just as
I'd have to.

wilson

unread,
Dec 8, 2009, 12:02:03 PM12/8/09
to
get image get from :
http://images.google.co.uk/imgres?imgurl=http://salmaworld.files.wordpress.com/2009/09/beautiful-face-wallpapers_11213_1280x1024.jpg&imgrefurl=http://www.mathworks.co.uk/matlabcentral/newsreader/search_results%3Fsearch_string%3Drgb2gray%26view%3Dtext&usg=__MNo8LkQe-DN9sfH4e5E7n5evko0=&h=1024&w=1280&sz=181&hl=en&start=74&itbs=1&tbnid=Drqc8jryXDj1gM:&tbnh=120&tbnw=150&prev=/images%3Fq%3Dface%26gbv%3D2%26ndsp%3D18%26hl%3Den%26sa%3DN%26start%3D72
I direct crop out the eyes
eyes = double(imread('eye234.jpg'))/255;
figure; imagesc(eyes);
axis equal tight off;
colormap gray;
title('eyes');

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);

wilson

unread,
Dec 10, 2009, 9:36:20 PM12/10/09
to
ImageAnalyst i still cant manage to get the boundry of the iris and retina error appear! I need your help!
One more question if the image of the eye got reflection how to get rid of the reflection need to apply a filter on it? oR?

ImageAnalyst

unread,
Dec 10, 2009, 10:23:21 PM12/10/09
to
I've given you dozens of lines of code that find the iris. You should
be able to handle it from here. I can't write a turnkey super-robust
application for you (unless you hire me). It's your job to take me
demo code that works with this one image you gave and make it work
with more images, including those with different eye colors, specular
reflections, etc.
Good luck.

satyam surendra

unread,
May 19, 2010, 1:44:04 AM5/19/10
to
"wilson " <wilson_s...@hotmail.com> wrote in message <hda6ns$oar$1...@fred.mathworks.com>...
> 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?


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....>???

0 new messages