a=imread('10.bmp');


%truecolor: three dimensions
a1=a(:,:,1);
a2=a(:,:,2);
a3=a(:,:,3);

N=size(a,1);
M=size(a,2);
zeropad=zeros(N,M);
a1pad=[a1 zeropad];
a2pad=[a2 zeropad];
a3pad=[a3 zeropad];

%initialize answer matrix
c1=zeros(N,2*M);
c2=zeros(N,2*M);
c3=zeros(N,2*M);


%horizontal shift. Cannot be larger than N.
shift=-80;

%initial image
y(:,:,1)=a1pad;y(:,:,2)=a2pad;y(:,:,3)=a3pad;
image(y);


for i=1:N,
      ffta=fft(a1pad(i,:));
   for m=1:2*M,
      ffta(m)=ffta(m)*exp(j*2*shift*(m-1)*pi/(2*M));
      
   end
   
   c1(i,:)=ifft(ffta);
end
   image(a1pad);
image(real(c1));


for i=1:N,
      ffta=fft(a2pad(i,:));
   for m=1:2*M,
      ffta(m)=ffta(m)*exp(j*2*shift*(m-1)*pi/(2*M));
      
   end
   
   c2(i,:)=ifft(ffta);
end
   image(real(c2));
image(a2pad);


for i=1:N,
      ffta=fft(a1pad(2,:));
   for m=1:2*M,
      ffta(m)=ffta(m)*exp(j*2*shift*(m-1)*pi/(2*M));
      
   end
   
   c3(i,:)=ifft(ffta);
end







   image(a1pad);
figure;
image(real(c3))


