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?
Y = circshift( A , K , dim ) circularly shifts the values in array A by K positions along dimension dim .
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With