logo       

How to view eigenfaces, Re: Re: Face recognition using eigenfaces: msg#01248

lib.opencv

Subject: How to view eigenfaces, Re: Re: Face recognition using eigenfaces

Hi,

How would I acutally normalise the Eigenfaces so that I can view
them?

Thanks,
Kirk

--- In OpenCV@xxxxxxxxxxxxxxx, "Salman Aslam" <salman.m.aslam@...>
wrote:
>
> thankyou Parameswaran.
>
> regards
>
> ----- Original Message -----
> From: Parameswaran
> To: OpenCV@xxxxxxxxxxxxxxx
> Sent: Wednesday, March 29, 2006 11:34 AM
> Subject: How to view eigenfaces, Re: [OpenCV] Re: Face
recognition using eigenfaces
>
>
> If you normalize the eigenface pixel values between 0 and 255,
you can
> view the image using the HighGUI window.
>
> Regards, :D
> Paramesh.
>
> --- In OpenCV@xxxxxxxxxxxxxxx, "Salman Aslam" <salman.m.aslam@>
wrote:
> >
> > is there a way to view the eigenfaces?
> >
> >
> > ----- Original Message -----
> > From: Parameswaran
> > To: OpenCV@xxxxxxxxxxxxxxx
> > Sent: Friday, March 17, 2006 9:10 PM
> > Subject: [OpenCV] Re: Face recognition using eigenfaces
> >
> >
> > You cant save float eigenfaces..
> > Because whenever you save floating point images, it is
converted into
> > unsigned char image.
> > So, the data will be lost.
> >
> > To save eigenfaces, try saving it as a text file, or
something..
> >
> > Regards, :D
> > Paramesh.
> >
> > --- In OpenCV@xxxxxxxxxxxxxxx, "yeewan84" <yeewan84@> wrote:
> > >
> > > Hi Paramesh,
> > >
> > > Thanks for checking the code for me.
> > >
> > > I've tried to calculate the weights without saving and
loading.
> > > It can recognize though result not so good. But does this
mean that
> > > everytime I want to recognize an input image, I've to
recalculate
> > > the eigenfaces? I'll be slow.
> > >
> > > I've tried with OpenCV inbuilt function. It works but the
same
> > > problem occur. I cant save n load the eigenfaces to
calculate the
> > > weight.
> > >
> > > Is there anyway, I can save the eigenfaces?
> > >
> > > rgds,
> > > evon
> > >
> > > --- In OpenCV@xxxxxxxxxxxxxxx, "Parameswaran"
<cegparamesh@>
> > > wrote:
> > > >
> > > > Sorry for being late...
> > > >
> > > > Looking at your code, i dont find any problem in the
algorithm
> you
> > > use.
> > > > Did you get your eigenfaces right?
> > > > Did it look like an eigenface?
> > > >
> > > > Why dont you try once, to calculate weights without
saving and
> > > loading
> > > > the eigenface?
> > > >
> > > > And did you take a look at the inbuilt functions for
doing PCA
> > > using
> > > > OpenCV?
> > > > Using CalcEigenObjects and CalcDecompCoeff?
> > > > If you didnt try that one, download the PCA.zip
attachment in the
> > > > group's files section..
> > > >
> > > > Regards, :D
> > > > Paramesh.
> > > >
> > > > --- In OpenCV@xxxxxxxxxxxxxxx, "yeewan84" <yeewan84@>
wrote:
> > > > >
> > > > > Hi Paramesh,
> > > > >
> > > > > Does it have to do with how I save the eigenfaces that
effect
> > > the
> > > > > weights calculation? After i calculate the eigenfaces,
I use it
> > > to
> > > > > calculate the weights of the training set, then save
the
> > > eigenfaces.
> > > > >
> > > > > For recognition, i load the eigenfaces then calculate
the
> weight
> > > of
> > > > > input image. Izit b'cos the eigenfaces values was
altered
> when i
> > > > > save it?
> > > > >
> > > > >
> > > > > rgds,
> > > > > evon
> > > > > --- In OpenCV@xxxxxxxxxxxxxxx, "yeewan84" <yeewan84@>
wrote:
> > > > > >
> > > > > > Hi,
> > > > > >
> > > > > > Izit because i put all image data to array?
> > > > > >
> > > > > > Training:
> > > > > >
> > > > > > //****load training set
> > > > > > float** inputImg;
> > > > > > inputImg = (float**) calloc(nObjects, sizeof
(float*));
> > > > > >
> > > > > > while( image ){
> > > > > > filename = imgPath + image;
> > > > > > temp = cvLoadImage(filename.c_str(), 0);
> > > > > > inputImg[count] = (float*) calloc(150*150, sizeof
(float));
> > > > > >
> > > > > > for(int y = 0; y < 150; y++)
{
> > > > >
> > > > > > for(int x = 0; x < 150; x++){
> > > > > > if( y == 0 || y == 1){
> > > > > > inputImg[count][(y*149)+x] =
> ((uchar*)(temp->imageData
> > > +
> > > > > > temp->widthStep * y))[x];
> > > > > >
> > > > > > //add up all value for calculate average
face later
> > > > > > average[(y*149)+x] += inputImg[count][(y*149)
+x];
> > > > > >
> > > > > > }else{
> > > > > > inputImg[count][((y-1)*149)+x] = ((uchar*)
(temp-
> > > >imageData
> > > > > +
> > > > > > temp->widthStep * y))[x];
> > > > > >
> > > > > > //add up all value for calculate average
face later
> > > > > > average[((y-1)*149)+x] += inputImg[count]
[((y-1)*149)
> > > +x];
> > > > > > }
> > > > > > }
> > > > > > }
> > > > > > count++;
> > > > > > image = strtok(NULL, ";");
> > > > > >
> > > > > > }
> > > > > >
> > > > > >
> > > > > > //******calculate average face
> > > > > > for(int y = 0; y < 150; y++){
> > > > > > for(int x = 0; x < 150; x++){
> > > > > > if( y == 0 || y == 1){
> > > > > > average[(y*149)+x] /= nObjects;
> > > > > > ((uchar*)(temp->imageData + temp->widthStep *
y))[x] =
> > > avg
> > > > > > [(y*149)+x];
> > > > > >
> > > > > > }else{
> > > > > > average[((y-1)*149)+x] /= nObjects;
> > > > > > ((uchar*)(temp->imageData + temp->widthStep *
y))[x] =
> > > avg
> > > > > [((y-
> > > > > > 1)*149)+x];
> > > > > > }
> > > > > > }
> > > > > > }
> > > > > >
> > > > > > //*****calculate difference face
> > > > > > for(y = 0; y < nObjects; y++)
> > > > > > for(x = 0; x < 150*150; x++)
> > > > > > inputImg[y][x] -= average[x];
> > > > > >
> > > > > >
> > > > > >
> > > > > > //****calculate covariance matrix
> > > > > > float** L;
> > > > > > L = (float**) calloc(nObjects, sizeof(float*));
> > > > > > for(int y = 0; y < nObjects; y++)
> > > > > > L[y] = (float*) calloc(nObjects, sizeof(float));
> > > > > >
> > > > > > for(int y = 0; y < nObjects; y++)
> > > > > > for(int x = 0; x < nObjects; x++)
> > > > > > L[y][x] = calcDotProduct(inputImg[y], inputImg
[x]);
> > > > > >
> > > > > >
> > > > > >
> > > > > > //***for eigenvector and eigenvalues, i use a math
library to
> > > > > compute
> > > > > >
> > > > > > //normalize eigenvector ||u||
> > > > > > double distance = 0, eigen = 0;
> > > > > > for(int i = 0; i < 150*150; i++)
> > > > > > distance += pow(eigenImg[i], 2);
> > > > > > distance = sqrt(distance);
> > > > > >
> > > > > > if(distance != 1)
> > > > > > for( int i = 0; i < 150*150; i++)
> > > > > > eigenImg[i] /= distance;
> > > > > > //the eigenface is scale by 10000 (*10000) before
saving
> > > > > >
> > > > > >
> > > > > > //****calculate weight
> > > > > > float **weight;
> > > > > > weight = (float **)calloc (nObjects, sizeof(float
*));
> > > > > >
> > > > > > for(int i = 0; i < nObjects; i++){
> > > > > > weight[i] = (float *)calloc (M, sizeof(float));
> > > > > > for(int j=0; j < M; j++)
> > > > > > weight[i][j] = calcDotProduct(eigenImg[j],
inputImg[i]);
> > > > > > }
> > > > > >
> > > > > > Recognition:
> > > > > > //load eigenfaces the same way as loading training
set above
> > > > > > //then scale the eigenface (divide by 10000)
> > > > > >
> > > > > > //calculate weight
> > > > > > for(int j=0; j < M; j++)
> > > > > > weight[j] = calcDotProduct( eigenImg[j],
test_image );
> > > > > > }
> > > > > >
> > > > > >
> > > > > > //euclidean distance
> > > > > > for(int j=0; j < nObjects; j++)
> > > > > > for(int k=0; k < M; j++)
> > > > > > x1 += pow((weight[k] - weight_in_db[j][k], 2);
> > > > > >
> > > > > > distance = sqrt(x1);
> > > > > >
> > > > > >
> > > > > > Thanks :)
> > > > > >
> > > > > > rgds,
> > > > > > evon
> > > > > >
> > > > > > --- In OpenCV@xxxxxxxxxxxxxxx, "Parameswaran"
<cegparamesh@>
> > > > > > wrote:
> > > > > > >
> > > > > > > Your weights and euclidean distance seems to be
correct.
> > > > > > > The Euclidean distance is not too big...
> > > > > > >
> > > > > > > >I dont get zero for euclidean distance when I use
the same
> > > input
> > > > > > > >image for calculating eigenface.
> > > > > > > >
> > > > > > > >Whatever test image I put to recognize, I always
get back
> > > that
> > > > > few
> > > > > > > >face for nearest face. For example, I have face
class 1 to
> > > 10,
> > > > > the
> > > > > > > >system always give me face class 2 and 5 for
nearest face
> > > > > classes.
> > > > > > >
> > > > > > > This is where i doubt something.
> > > > > > > The Euclidean distance should be zero if the test
image is
> > > the
> > > > > > same as
> > > > > > > the face database.
> > > > > > >
> > > > > > > Well. What can i suggest you now?
> > > > > > > Take a look at your code in detail.
> > > > > > > If you are calculating the weights and euclidean
distance
> > > the
> > > > > same
> > > > > > way
> > > > > > > for the test image, then Euclidean distance should
be zero.
> > > > > > > What is the euclidean distance when you get, if
you give
> the
> > > test
> > > > > > > image as the same on in database?
> > > > > > > Is it less than 1000 or 2000? It should be..
> > > > > > > Else something went wrong somewhere.
> > > > > > >
> > > > > > > Regards, :D
> > > > > > > Paramesh.
> > > > > > >
> > > > > > > PS: Last but not the least, if you cant find the
error,
> > > paste the
> > > > > > > entire code. I'll look through it and try to find
the error
> > > if i
> > > > > > can.
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --- In OpenCV@xxxxxxxxxxxxxxx, "yeewan84"
<yeewan84@> wrote:
> > > > > > > >
> > > > > > > > Hi,
> > > > > > > >
> > > > > > > > Sample weights:
> > > > > > > > -112.83, -1067.05, 1654.81, -4087.68, 2575.40, -
1806.17,
> > > > > 1013.89
> > > > > > > >
> > > > > > > > Sample euclidean distance:
> > > > > > > > 8599.753906, 9766.369141, 9910.776367,
9836.765625,
> > > > > 11140.266602,
> > > > > > > > 10934.599609, 9329.093750
> > > > > > > > (izit too big?)
> > > > > > > >
> > > > > > > > this is how i calculate the distance:
> > > > > > > > for(int i = 0; i < M; i++){
> > > > > > > > x += pow((input_weight[k] - weight[k]), 2);
> > > > > > > > }
> > > > > > > > distance = sqrt(x);
> > > > > > > >
> > > > > > > > Sample eigenfaces image data:
> > > > > > > > 6.44592935e-010, 2.57854227e-009, 4.14895069e-
008,
> > > > > > > > 1.03723776e-008, 9.90167757e-012, 2.59315036e-
009,
> > > > > > > > 1.59329189e-010, 1.66892988e-007, 6.78776985e-
007,
> > > > > > > > (I've normalize the eigenfaces to be in unit
length,
> > > ||u|| )
> > > > > > > >
> > > > > > > > Thank you very much :)
> > > > > > > >
> > > > > > > > rgds,
> > > > > > > > evon
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> >
> >
> >
> >
> >
> > Change settings: http://www.yahoogroups.com/mygroups, select
> > Get Emails (get all posts)
> > Daily Digest (one summary email per day)
> > Read on the web (read posts on the web only)Or
Unsubscribe by
> mailing OpenCV-unsubscribe@xxxxxxxxxxxxxxx
> >
> >
> >
> >
> > SPONSORED LINKS Open source software Computer vision
> >
> >
> >
> -----------------------------------------------------------------
-------------
> > YAHOO! GROUPS LINKS
> >
> > a.. Visit your group "OpenCV" on the web.
> >
> > b.. To unsubscribe from this group, send an email to:
> > OpenCV-unsubscribe@xxxxxxxxxxxxxxx
> >
> > c.. Your use of Yahoo! Groups is subject to the Yahoo!
Terms of
> Service.
> >
> >
> >
> -----------------------------------------------------------------
-------------
> >
> >
> >
> > [Non-text portions of this message have been removed]
> >
>
>
>
>
>
>
>
> Change settings: http://www.yahoogroups.com/mygroups, select
> Get Emails (get all posts)
> Daily Digest (one summary email per day)
> Read on the web (read posts on the web only)Or Unsubscribe by
mailing OpenCV-unsubscribe@xxxxxxxxxxxxxxx
>
>
>
>
> -------------------------------------------------------------------
-----------
> YAHOO! GROUPS LINKS
>
> a.. Visit your group "OpenCV" on the web.
>
> b.. To unsubscribe from this group, send an email to:
> OpenCV-unsubscribe@xxxxxxxxxxxxxxx
>
> c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms
of Service.
>
>
> -------------------------------------------------------------------
-----------
>
>
>
> [Non-text portions of this message have been removed]
>






Change settings: http://www.yahoogroups.com/mygroups, select
Get Emails (get all posts)
Daily Digest (one summary email per day)
Read on the web (read posts on the web only)Or Unsubscribe by mailing
OpenCV-unsubscribe@xxxxxxxxxxxxxxx



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise