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
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