function [imarray,movieframes] = MakePlaidMovie(c1,c2,th,speedratio) % c1: Contrast of the first component (should be [0,1]) % c2: Contrast of the second component (should be [0,1]) % th: Angle between the components in degrees % speedratio: ratio between the speeds of the two components % applied to the first component (the speed of the 2nd % component is fixed) theta = th*pi/180; imsize = 64; T = 32; [X,Y]=meshgrid( 2*pi*(0:(imsize-1))/imsize,2*pi*(0:(imsize-1))/imsize); CosIm1 = cos(2*(cos(theta/2)*X+sin(theta/2)*Y)); SinIm1 = sin(2*(cos(theta/2)*X+sin(theta/2)*Y)); CosIm2 = cos(2*(cos(-theta/2)*X+sin(-theta/2)*Y)); SinIm2 = sin(2*(cos(-theta/2)*X+sin(-theta/2)*Y)); mask = exp(-0.5*((X-pi).^2+(Y-pi).^2)); maxc = max(c1,c2); for t=1:T, imarray(:,:,t) = min(maxc,c1*(sin(2*speedratio*pi*t/T)*CosIm1+cos(2*speedratio*pi*t/T)*SinIm1).^4+... c2*(sin(2*pi*t/T)*CosIm2+cos(2*pi*t/T)*SinIm2).^4); imarray(:,:,t) = mask.*imarray(:,:,t); movieframes(t) = im2frame(uint8(imarray(:,:,t)*256),gray(256)); end