% Water.m 水面に映す
Width=100; XX=imread('C:\FreeMat\8_9_Water\Water.jpg');
XX=double(XX)./255; XXf=flipud(XX); % MATLABでは flip(XX)
YY=zeros(size(XX));
for kkk=1:11
for i=1:size(XX,1)
for j=1:size(XX,2)
b=j/size(XX,2)*Width*(size(XX,1)/i/1)+(kkk-1)*1;
y1=round(sin(b)*30); y2=j+y1;
if y2>size(XX,2) y2=size(XX,2); end; if y2<=0 y2=1; end
YY(i,j,:)=XXf(i,y2,:);
end
end
YY=YY./1.5; YYY=zeros(size(XX,1)*2,size(XX,2),3);
YYY(1:size(XX,1),:,:)=XX; YYY(size(XX,1)+1:size(XX,1)*2,:,:)=YY;
LabelA=[char('C:\FreeMat\8_9_Water\Water'), num2str(kkk,'%03d'),char('.jpg')];
imwrite(YYY,LabelA);
end
% WaterCircle.m 丸い波紋に映す
Sinpk=100; Shuki=0.05; A=[1,0.5;0.5,1]; C=[300;500];
XX=imread('C:\FreeMat\8_9_Water\Madonna2.jpg');
XX=double(XX)./255; YY=zeros(size(XX)); XXf=flip(XX); % flipud MATLABでは flip(XX)
for kkk=1:7
for i=1:size(XX,1)
for j=1:size(XX,2)
P=[i;j]; V=P-C;
d1=sqrt(V'*A*V); d2=sin(d1*Shuki+(kkk-1)*1)*Sinpk;
d=d1+d2; if d1==0 Y=C; else Y=ceil(V*d/d1+C); end
if Y(2)>size(XX,2) Y(2)=size(XX,2); end; if Y(2)<=0 Y(2)=1; end
if Y(1)>size(XX,1) Y(1)=size(XX,1); end; if Y(1)<=0 Y(1)=1; end
YY(i,j,:)=XXf(Y(1),Y(2),:);
end
end
YY=YY./1.5; YYY=zeros(size(XX,1)*2,size(XX,2),3);
YYY(1:size(XX,1),:,:)=XX; YYY(size(XX,1)+1:size(XX,1)*2,:,:)=YY;
LabelA=[char('C:\FreeMat\8_9_Water\Madonna円'), num2str(kkk,'%03d'),char('.jpg')];
imwrite(YYY,LabelA);
end
カラー写真をカラフルな絵にする(FreeMat)
setpath('C:\FreeMat\4_8_MyColormap')
XX=imread('すいれん.jpg'); XX=double(XX)./255;
YY=(sin(XX*5*pi)+1)/4+XX./2;
image(YY); imwrite(YY,'すいれん10.jpg');