Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do a horizontal shift of an image in MATLAB?

Tags:

image

matlab

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?

like image 842
user2192778 Avatar asked Mar 20 '13 21:03

user2192778


People also ask

How do you shift rows in Matlab?

Y = circshift( A , K , dim ) circularly shifts the values in array A by K positions along dimension dim .

How do you transform an image in Matlab?

B = imtransform( A , tform ) transforms image A according to the 2-D spatial transformation defined by tform , and returns the transformed image, B . If A is a color image, then imtransform applies the same 2-D transformation to each color channel.


1 Answers

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

affine translation

like image 86
Amro Avatar answered Nov 05 '22 23:11

Amro