How to make horizontal image shift in MATLAB?

I have an image that I converted to a double matrix. I want to move it horizontally, but I'm not sure how to do it. I try to manipulate the position, but it turns out that I only manipulate color.

Is there a way that I can refer to the pixel position instead, and then add a constant to do the shift?

+5
source share
3 answers

Using the Image Processing Tool, you can apply 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

affine translation

+8
source

You can use circshiftto perform a circular shift im = circshift(im, [vShift hShift]).

+5
source

, - A, x :

A = [A(x+1:end,:) A(1:x,:)];
+2

All Articles