Re: pls help me to complete my final year project pls pls..
- From: "Mersalin " <josh.expectation@xxxxxxxxx>
- Date: Fri, 18 Dec 2009 06:29:03 +0000 (UTC)
"Mersalin " <josh.expectation@xxxxxxxxx> wrote in message <hgf747$gv9$1@xxxxxxxxxxxxxxxxxx>...
Rune Allnor <allnor@xxxxxxxxxxxx> wrote in message <477d0325-bbf6-4b8d-ab61-045961e50618@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>...
> On 18 Des, 07:00, "Mersalin " <josh.expectat...@xxxxxxxxx> wrote:
> > ??? Undefined function or variable "filename".
> >
> > Error in ==> findface at 134
> > save([filename(1:end-3),'mat']);.
> >
> > This was an error occured while i running my final year project on image recognition... can u help me to solve this error.... please pls pls....
> > The general procedure goes something like
> > 1) Read the error message
> 2) Contemplate the error message
> 3) Use a debugegr to step through the
> code to check details.
> > In your case steps 1) and 2) ought to suffice,
> since the message is:
> > ??? Undefined function or variable "filename".
> > Any suggestions what might casue that sort of
> error message...?
> > Rune
no.. i donno .. i just got the code from net...
The full code:
function [Results,Guess,CLab,Correct_size,CLabsum,meatdif,CLabsumMeat,CLabsumMax,newI]=findface(a) % Here i replaced 'filename' by 'a' bcos my input file is 'a.jpg'
% This function finds all the faces in the image named 'filename'
% 'newI' RGB image with green squares around the faces.
my_threshold=0.7;
%Absolut threshold for face existence
my_face_threshold=12;
meat_factor=2;
meat_threshold=15;
bar=waitbar(0,'Loading image');
Irgb=image_resize('a.jpg',800); % here also i renamed
[imx,imy,imz]=size(Irgb);
M=makecform('srgb2lab');
I=applycform(Irgb,M);
waitbar(0,bar,'Looking for the correct size');
%Load the template names.
template_names=dir('../caras/*.jpg');
CLab=zeros(imx,imy,length(template_names));
Correct_size=zeros(length(template_names),1);
sizes=[400;365;330;295;260;225;190;155;120;85;50];
[Correct_size(1),maximum,CLab(:,:,1)]=trysizes(I,template_names(1).name,M,sizes);
for k=2:length(template_names)
waitbar(k/length(template_names),bar,'Comparing faces')
%In each template we take the average of the previous sizes and try the
%correlation with the one closest to the average, the one inmidiately
%higher and the one inmideately lower.
sizes=give_sizes(Correct_size);
%Calculate correlations values.
[Correct_size(k),maximum,CLab(:,:,k)]=trysizes(I,template_names(k).name,M,sizes);
end
close(bar)
%Sum all correlations
CLabsum=sum(CLab,3);
%This functions loads all the templates, averages the (a,b) values in all
%of them and also averages between them, providing the two averages.
[m1,m2]=calculate_mean;
%We calculate the distance in (a,b) coordinates from each point to the
%calculated averages.
meatdif=sqrt((double(I(:,:,2))-m1).^2+(double(I(:,:,3))-m2).^2);
%Now we pass that difference through a sigmoid that will determine if the
%color is close enough to be considered flesh (in which case the value is
%meat_factor) or not (in which case the value is -meat_factor). If the
%distance is smaller than meat_threshold then it is considered flesh.
meat=2*meat_factor.*sigmf(meatdif,[-1 meat_threshold])-meat_factor;
%We add that matrix to the calculated correlations.
CLabsumMeat=CLabsum+meat;
%Look if there is any face in the picture
if (max(max(CLabsumMeat))<my_face_threshold)
sprintf('No face found in the picture')
%This indicates how to draw the result images.
noface=1;
else
noface=0;
end
CLabsumMeat2=CLabsumMeat;
%To eliminate undesired local maxima we make zero all those points that are
%lower than 70% of the highest peak.
CLabsumMeat2(find(CLabsumMeat2<(my_threshold.*max(max(CLabsumMeat2)))))=zeros(size(CLabsumMeat2(find(CLabsumMeat2<(my_threshold.*max(max(CLabsumMeat2)))))));
%We calculate the local maxima among those points that were above the
%threshold, which gives us a series of peaks.
CLabsumMax=(CLabsumMeat2.*localmax(CLabsumMeat2))./max(max(CLabsumMeat2));
%These peaks are the first guess of face coordinates.
[X,Y]=ind2sub(size(CLabsumMax),find(CLabsumMax>0));
Z=CLabsumMax(find(CLabsumMax>0));
Guess=[Z,X,Y];
Guess=sortrows(Guess,-1);
%Tipically several peaks appear in each face due to the differences between
%the templates and the effect of the flesh function. For this reason, those
%peaks that are in a diameter 40% bigger the average template size are
%considered to be the same face. This 40% accounts for the fact that the
%templates do not include the whole head, and that we do not know where the
%center of the face is exactly.
Results=my_clusters2(Guess,Correct_size);
%Given the final coordinates, green boxes are drawn around each face.
[newI,newI2]=draw_faces2(Results,Guess,Irgb,Correct_size,noface);
%All the results are saved.
save([filename(1:end-3),'mat']);
imwrite(newI2,[filename(1:end-4),'_faces2.jpg']);
imwrite(meatdif./max(max(meatdif)),[filename(1:end-4),'_meatdif.jpg']);
imwrite((CLabsumMeat-CLabsum)./max(max(CLabsumMeat-CLabsum)),[filename(1:end-4),'_meatonly.jpg']);
imwrite(newI,[filename(1:end-4),'_faces.jpg']);
imwrite(CLabsum./max(max(CLabsum)),[filename(1:end-4),'_sum.jpg']);
imwrite(CLabsumMeat./max(max(CLabsumMeat)),[filename(1:end-4),'_meat.jpg']);
.
- Follow-Ups:
- Re: pls help me to complete my final year project pls pls..
- From: Sebastian Hölz
- Re: pls help me to complete my final year project pls pls..
- References:
- pls help me to complete my final year project pls pls..
- From: Mersalin
- Re: pls help me to complete my final year project pls pls..
- From: Rune Allnor
- Re: pls help me to complete my final year project pls pls..
- From: Mersalin
- pls help me to complete my final year project pls pls..
- Prev by Date: Re: pls help me to complete my final year project pls pls..
- Next by Date: Re: Error with median?
- Previous by thread: Re: pls help me to complete my final year project pls pls..
- Next by thread: Re: pls help me to complete my final year project pls pls..
- Index(es):
Relevant Pages
|