Figure out who the following people are.
unswirled
The code:
function[B]= unswirl(inpic,r,gamma)
inpic=double(inpic)/255;
cx=size(inpic,1)/2;
cy =size(inpic,2)/2;
for x=1:size(inpic,1)
for y=1:size(inpic,2)
d=sqrt((x-cx)^2+(y-cy)^2);
if ((d>r)|(d&gl1))
B(x,y,:)=inpic(x,y,:);
else
if (y>cy)
theta=acos((x-cx)/d);
else
theta=-acos((x-cx)/d);
end
fr=(d/r)^2*(1-d/r)^2*16;
newx=d*cos(theta+gamma*fr)+cx
newy=d*sin(theta+gamma*fr)+cy
ro=floor(newx);
s=floor(newy);
for k=1:3
B(x,y,k)=[1-newx+ro,newx-ro]*[inpic(ro,s,k),inpic(ro,s+1,k);inpic(ro+1,s,k),inpic(ro+1,s+1,k)]*[1-newy+s;newy-s];
end
end
end
end
end
inpic=imread('swirled1.jpg');
image(unswirl(inpic,180,(-3*pi))
Second image:
Code:
function[B]= unswirl(inpic,r,gamma)
inpic=double(inpic);
cx=size(inpic,1)/2;
cy =size(inpic,2)/2;
for x=1:size(inpic,1)
for y=1:size(inpic,2)
d=sqrt((x-cx)^2+(y-cy)^2);
if ((d>r)|(d&gl1))
B(x,y)=inpic(x,y);
else
if (y>cy)
theta=acos((x-cx)/d);
else
theta=-acos((x-cx)/d);
end
fr=(d/r)^2*(1-d/r)^2*16;
newx=d*cos(theta+gamma*fr)+cx
newy=d*sin(theta+gamma*fr)+cy
ro=floor(newx);
s=floor(newy);
B(x,y)=[1-newx+ro,newx-ro]*[inpic(ro,s),inpic(ro,s+1);
inpic(ro+,s),inpic(ro+1,s+1)]*[1-newy+s;newy-s];
end
end
end
inpic=imread('swirled # 2.jpg');
colormap(gray(256));
image(unswirl2(inpic,150,(3*pi)))
Sunday, June 15, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment