Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Shifting an image using the image processing toolbox

Status
Not open for further replies.

urquidio

Electrical
Jun 25, 2004
1
Hi there,

I would like to use the 'affine' transformation in the image processing toolbox to quickly
shift an image in MATLAB.

Currently, I have the following code:

% -------------------------------------------------
% read in the image
I = imread('lena.tif');

% transform
T = maketform('affine',[1 0 0; 0 -1 0 ; 0 0 1]);
I2 = imtransform(I,T);

% show the result
imshow(I2)
% -------------------------------------------------


this flips the image I upside down. Now i want to shift
it by a certain amount, say del_x pixels in the x direction
and del_y in the y direction.

I'm thinking that i need to add a shift into the transformation, which seems to me that it should be added
in the last column of the matrix:

T = maketform('affine',[1 0 x; 0 -1 y ; 0 0 1]);
or something like that. but MATLAB requires that the last column is [0, 0, 1]. how do you get around this to get the affine transformation to perform a shift of the image?

thanks in advance

-M
 
Replies continue below

Recommended for you

I actually have a similar need as well, but instead of a uniform shift in x, I'd like to have the shift in x be a function of y. Not sure this is even possible, but it's worth a try since right now, I am shifting pixel by pixel in with a fortran script.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor