Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations JAE 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
Joined
Jun 25, 2004
Messages
1
Location
US
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
 
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

Back
Top