function faceid = curvestrnsf(im1)
%imshow(im1);
j=im1;
imshow(j);
bw1=edge(j,'canny',[0.002 0.15],1);
imshow(bw1);
[ro co]=size(j);
temp=zeros(ro, co);
mid_ro=round(ro/2);
mid_co= round(co/2);
if (mid_ro<mid_co)
r1=mid_ro-10;
else
r1=mid_co-10;
end
new_count=0;
for r=5:r1
for mid_ro=r+1:ro-r-1
count=0;
for x=mid_ro-r :mid_ro+r
%x=round(sqrt(2500-(y-mid_co)*(y-mid_co))+mid_ro);
p=x-mid_ro;
q1=round((r*r)-(p*p));
q=sqrt(q1);
y=round(q+mid_co);
if bw1(x,y)==1
count=count+1;
end
y=round(mid_co-q);
if bw1(x,y)==1
count=count+1;
end
if count >new_count
new_count=count;
x_fc=mid_ro;
y_fc=mid_co;
r_fc=r;
end
end
end
end
mid_ro=x_fc;
mid_co=y_fc;
r=r_fc;
for x=mid_ro-r :mid_ro+r
%x=round(sqrt(2500-(y-mid_co)*(y-mid_co))+mid_ro);
p=x-mid_ro;
q1=round((r*r)-(p*p));
q=sqrt(q1);
y=round(q+mid_co);
temp(x,y)=im1(x,y);
j(x,y)=255;
y=round(mid_co-q);
j(x,y)=255;temp(x,y)=im1(x,y);
end
c=0;
x2=1;
x1=mid_ro-1;
y1=mid_co;
for y2=50:50:200
m=round((y1-y2)/(x1-x2));
for x=mid_ro:-1:x2
y=round(m*x+c);
if (y>0)
j(x,y)=255;
temp(x,y)=im1(x,y);
end
end
end
for x2=50:50:200
m=round((y1-y2)/(x1-x2));
for y=mid_ro:-1:y2
x=round((y-c)/m);
if (x>0)
j(x,y)=255;
temp(x,y)=im1(x,y);
end
end
end
y=1;
%for x=1:mid_ro
y=y+1;
j(x,y)=255;
temp(x,y)=im1(x,y);
%end
x=1;
%for y=mid_co:co
x=x+1;
j(x,y)=255;
temp(x,y)=im1(x,y);
%end
x=mid_ro;
%for y=mid_co:co
j(x,y)=255;
temp(x,y)=im1(x,y);
%end
y=mid_co;
%for x=mid_ro:ro
j(x,y)=255;
temp(x,y)=im1(x,y);
%end
%for x=1:mid_ro
%j(x,y)=255;
%y=y+1;
%end
imshow(j);title('Checking','FontWeight','bold','Fontsize',16,'color','blue');
faceid=j;
%j=im1;
pause(1);
mid_ro=x_fc;
mid_co=y_fc;
r=r_fc-10;
for x=mid_ro-r :mid_ro+r
%x=round(sqrt(2500-(y-mid_co)*(y-mid_co))+mid_ro);
p=x-mid_ro;
q1=round((r*r)-(p*p));
q=sqrt(q1);
y=round(q+mid_co);
j(x,y)=255;
temp(x,y)=im1(x,y);
y=round(mid_co-q);
j(x,y)=255;
temp(x,y)=im1(x,y);
end
imshow(j);title('Checking','FontWeight','bold','Fontsize',16,'color','blue');
pause(0.5);
faceid=j;
%j=im1;
pause(1);
mid_ro=x_fc;
mid_co=y_fc;
r=r_fc-5;
for x=mid_ro-r :mid_ro+r
%x=round(sqrt(2500-(y-mid_co)*(y-mid_co))+mid_ro);
p=x-mid_ro;
q1=round((r*r)-(p*p));
q=sqrt(q1);
y=round(q+mid_co);
j(x,y)=255;
temp(x,y)=im1(x,y);
y=round(mid_co-q);
j(x,y)=255;
temp(x,y)=im1(x,y);
end
imshow(j);title('Checking','FontWeight','bold','Fontsize',16,'color','blue');
pause(0.5);
faceid=j;
%j=im1;
pause(1);
mid_ro=x_fc;
mid_co=y_fc;
r=r_fc-3;
for x=mid_ro-r :mid_ro+r
%x=round(sqrt(2500-(y-mid_co)*(y-mid_co))+mid_ro);
p=x-mid_ro;
q1=round((r*r)-(p*p));
q=sqrt(q1);
y=round(q+mid_co);
j(x,y)=255;
temp(x,y)=im1(x,y);
y=round(mid_co-q);
j(x,y)=255;
temp(x,y)=im1(x,y);
end
imshow(j);title('Checking','FontWeight','bold','Fontsize',16,'color','blue');
pause(0.5);
faceid=j;
%j=im1;
pause(1);
mid_ro=x_fc;
mid_co=y_fc;
r=r_fc-8;
for x=mid_ro-r :mid_ro+r
%x=round(sqrt(2500-(y-mid_co)*(y-mid_co))+mid_ro);
p=x-mid_ro;
q1=round((r*r)-(p*p));
q=sqrt(q1);
y=round(q+mid_co);
j(x,y)=255;
temp(x,y)=im1(x,y);
y=round(mid_co-q);
j(x,y)=255;
temp(x,y)=im1(x,y);
end
imshow(j);title('Checking','FontWeight','bold','Fontsize',16,'color','blue');
pause(0.5);
%for x=1:mid_ro;
y=y+1;
if (x<ro)
if(y<co)
j(x,y)=255;
temp(x,y)=im1(x,y);
end
end
%end
%for x=mid_ro:ro;
y=y+1;
if (x<ro)
if(y<co)
j(x,y)=255;
temp(x,y)=im1(x,y);
end
end
%end
%for x=1:mid_co;
y=y-1;
if (x<ro)
if(y<co)
j(x,y)=255;
temp(x,y)=im1(x,y);
end
end
%end
%for x=mid_co:co;
y=y-1;
if (x<ro)
if(y<co)
j(x,y)=255;
temp(x,y)=im1(x,y);
end
end
%end
x=mid_ro;
for y=1:mid_co;
if (x<ro)
if(y<co)
j(x,y)=255;
temp(x,y)=im1(x,y);
end
end
end
for y=mid_co:co;
if (x<ro)
if(y<co)
j(x,y)=255;
temp(x,y)=im1(x,y);
end
end
end
y=mid_co;
for x=1:mid_ro;
if (x<ro)
if(y<co)
j(x,y)=255;
temp(x,y)=im1(x,y);
end
end
end
for x=mid_ro:ro;
if (x<ro)
if(y<co)
j(x,y)=255;
temp(x,y)=im1(x,y);
end
end
end
imshow(j);title('Checking','FontWeight','bold','Fontsize',16,'color','yellow');
face_id=temp;
pause(1);
end
评论0