Cl;
Delta_x = 67; % must be an integer. The offset of horizontal movement. The value is right, and the negative value is left.
Delta_y =-89; % must be an integer. The offset of vertical movement is downward, and the negative value is upward.
Img1_imread('corner.png '); % here V is the height of the original image, U is the width of the original image
Imshow (IMG); % here Y is the height of the transformed image, and X is the width of the transformed Image
[V u] = size (IMG );
Imgn = zeros (V + ABS (delta_y), u + ABS (delta_x ));
Rot = [1 0 0; 0 1 0; delta_y delta_x 1];
Inv_rot = inv (ROT );
Pix1 = [1 1] * rot; % pix1 (1), pix1 (2) are the Y, X
Pix4 = [v U 1] * rot; % pix4 (1), pix4 (2) are respectively y, X
% Move to bottom right
If delta_x> = 0 & delta_y> = 0
For Y = pix1 (1): pix4 (1)
For x = pix1 (2): pix4 (2)
PIX = [Y x 1] * inv_rot;
If pix (1)> = 0.5 & pix (2)> = 0.5 & pix (1) <= V & pix (2) <= u
Imgn (Y, x) = IMG (round (pix (1), round (pix (2 )));
End
End
End
End
% Move to lower left
If delta_x <0 & delta_y> = 0
For Y = pix1 (1): pix4 (1)
For x = pix1 (2): pix4 (2)
PIX = [Y x 1] * inv_rot;
If pix (1)> = 0.5 & pix (2)> = 0.5 & pix (1) <= V & pix (2) <= u
Imgn (Y, x-delta_x) = IMG (round (pix (1), round (pix (2 )));
End
End
End
End
% Move to the top left
If delta_x <0 & delta_y <0
For Y = pix1 (1): pix4 (1)
For x = pix1 (2): pix4 (2)
PIX = [Y x 1] * inv_rot;
If pix (1)> = 0.5 & pix (2)> = 0.5 & pix (1) <= V & pix (2) <= u
Imgn (y-delta_y, x-delta_x) = IMG (round (pix (1), round (pix (2 )));
End
End
End
End
% Move to top right
If delta_x> = 0 & delta_y <0
For Y = pix1 (1): pix4 (1)
For x = pix1 (2): pix4 (2)
PIX = [Y x 1] * inv_rot;
If pix (1)> = 0.5 & pix (2)> = 0.5 & pix (1) <= V & pix (2) <= u
Imgn (y-delta_y, x) = IMG (round (pix (1), round (pix (2 )));
End
End
End
End
Figure, imshow (uint8 (imgn ))