×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Shifting an image using the image processing toolbox

Shifting an image using the image processing toolbox

Shifting an image using the image processing toolbox

(OP)
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

RE: Shifting an image using the image processing toolbox

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.  

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources