I am trying to build a simple function to translate the pixels of an image following the x axis and the y axis.To do so, I am using the following pseudo algorithm we saw in class:
- Compute the DFT of the image I
Multiply each I(k,l) by exp(-2*ipix*l/L)*exp(-2*ipik/L)
Compute the inverse fourrier transform of the previous matrix considering that the image have 3 channels (Red ,green and blue).
The instruction 2 have to be done for each one. Now here is my matlab implementation.My problem is that the output image is not translated.Does any one have any suggestion?
function [translatedImage ] = TranslateImage( image,x,y )
FreqImage=fft2(image);
S=size(image);
M=S(1,1);
L=S(1,2);
for j=1:3
for m=1:M
for l=1:L
FreqImage(m,l,j)=FreqImage(m,l,j)*exp(2*i*pi*m*x/M)*exp(2*i*pi*l*y/L);
end
end
end
translatedImage=ifft2(FreqImage);