Image movement involves the move function, which is implemented as follows:
Close all; % close all current graphics windows, empty workspace variable, clear workspace all variables clear all;clc;i=imread (' lenna.bmp '); % input image a=50;b=50;% set translation coordinates j1=move (i,a,b);% Move original image a=-50;b=50;% set translation coordinates j2=move (i,a,b);% Move original image a=50;b=-50;% set translation coordinates j3=move (I, b);% move original image a=-50;b=-50;% set translation coordinate J4=move (i,a,b);% Move original image set (0, ' defaultfigureposition ', [100,100,1000,500]);% Modify the default settings for the location of the graphic image set (0, ' Defaultfigurecolor ', [1 1 1])% modify the setting of the background color of the graphic Figure,subplot (1,2,1), Imshow (J1), Axis on;% After drawing the Moving Image subplot (1,2,2), Imshow (J2), Axis on;% draw the Moving Image Figure,subplot (1,2,1), Imshow (J3), Axis on;% draw the Moving Image subplot (1,2,2) , Imshow (J4), Axis on;% draw the post-move image
As follows:
MATLAB: Moving the image (move function)