matlab 波纹扭曲

% 波纹扭曲
img=imread('pic.jpg');

img=im2double(img);
[h,w,c]=size(img);
ratio=600/(h+w);
img=imresize(img,ratio);
[h,w,c]=size(img);

wave=[10,200];  %幅度、周期
newh=h+2*wave(1);
neww=w+2*wave(1);
rot=0;

imgn=zeros(newh,neww,3);

while 1
    
    rot=rot+0.3;
    for y=1:newh
        for x=1:neww
            yy=round((y-wave(1))+(wave(1)*cos(2*pi/wave(2)*x+rot  )));
            xx=round((x-wave(1))+(wave(1)*cos(2*pi/wave(2)*y+rot )));
            
            if yy>=1&&yy<=h&&xx>=1&&xx<=w
                imagn(y,x,1)=img(yy,xx,1);
                imgn(y,x, 2)=img(yy,xx, 2);
                imgn(y,x, 3)=img(yy,xx, 3);
            end
        end
    end
    imshow(imgn,[]);
end

  while 1

无限循环,可以改为 for 循环,确定次数变化图像

朝闻道
原文地址:https://www.cnblogs.com/wander-clouds/p/8848418.html