# Producing images with subpixel shift in region of interest

Let's say for a zebra image, and at certain pixel location, I would like to makes it "vibrate/warp" to and fro in horizontal direction at a certain frequencies in a sequence of images of time t, with subpixel shift. The circled area is the most significant area that I intended to simulate the vibration. Those images will be mainly used for synthetic motion estimation. In MATLAB, the the zebra image can be produced using the following code:

m=75;
n=75;
stripe_px=1;
single_pattern=[ones(m,stripe_px),zeros(n,stripe_px)];
zebra=repmat(single_pattern,[1 ceil(n/stripe_px*2)]);
zebra=zebra(:,1:n);


The magnitude of the subpixel shift indicates by this map below: Also can be produce by MATLAB code:

X=repmat(1:m,[n 1]);
Y=repmat((1:n)',[1 m]);
Shape=0.04*( ((((X/m)-0.75).^2).*X) - ((((Y/n)-0.75).^2).*Y) );


Based on the information that I currently have, what's my next step? I was looking at imwarp (link), but I'm not sure if it can shift local pixels, where usually it was meant for whole image transform. And its usage is very vague for me. A simple pseudocode to depict what I'm trying to achieve would be:

omega=3;
T=30;
Fs=20;
dt=1/Fs;
for t=0:dt:T
vibrate_im=(zebra + Shape) + sin(omega*t);
end


Can a wavelet transform be used for this subtle pixel shifting? If so how do I manipulate its coefficients?

Appreciate any input and help! Thanks in advance.

• I don't use image processing toolbox, but I would look at interp2() – Knut Inge Mar 1 at 5:52

I tried to distill your question down to a 1-d problem. Does this "moving sine" do ~what you want to do?

t = 0:50;
f = (1/4)/5;
x = sin(2*pi*f*t);
nsteps = 50;
figure(1),
clf
ylim([-1 1])
xlim([0 nsteps])
stepvect = linspace(0,3,nsteps);
stepvect = [stepvect stepvect((end-1):-1:2)];
for step = 1:length(stepvect)
y = interp1(t, x, t+stepvect(step)*sin(pi*t/50), 'linear');
plot(t, y)
grid on
drawnow;
end