I have an RGB image that I would like to animate by applying increasing amounts of phase shift to it. An example of what I am trying to achieve is shown here: Example mov (although note that this is two images superimposed with phase offset in opposite directions). An example of my code looks like this:
Stim = ind2rgb(X,map);
NoFrames = 10;
FrameShift = linspace(0,2*pi,NoFrames);
for f = 1:numel(FrameShift)
F = fft2(Stim);
mag = abs(F);
phase = angle(F)+ FrameShift(f);
phase = wrapTo2Pi(phase);
ShiftedImage = mag.*exp(j*phase);
PhaseStim = real(ifft2(ShiftedImage));
Range = max(max(max(PhaseStim))) - min(min(min(PhaseStim)));
PhaseStim = uint8(((PhaseStim - min(min(min(PhaseStim))))/Range)*255);
title(['FFT phase = ',num2str(FrameShift(f)/pi),' * pi']);
The RGB image output looks correct when the phase offset is 0 or 2*pi (identical to the original image) and at pi (contrast inversion of the original image). However, at all phase offsets in between, the image appears not to change. I noticed that if I change the number of frames (NoFrames) to 5 then when phase offset is pi/2, the image output does change, but not in the way I expect.
Please can anybody suggest what I might be doing wrong?