How to do a horizontal shift of an image in MATLAB?
image, matlab
Solution
Using the Image Processing Toolbox, you can apply a spatial transformation:
img = imread('pout.tif');
T = maketform('affine', [1 0 0; 0 1 0; 50 100 1]); %# represents translation
img2 = imtransform(img, T, ...
'XData',[1 size(img,2)], 'YData',[1 size(img,1)]);
subplot(121), imshow(img), axis on
subplot(122), imshow(img2), axis on
Problem
I have an image that I have converted into a double matrix. I want to shift it horizontally, but I am not sure how to do this. I try to manipulate the position, but it turns out that I am only manipulating the color. Is there a way that I can reference the pixel position instead and then add a constant to perform a shift?