MATLAB,移动图像

时间:2012-04-23 09:39:12

标签: image matlab animation matlab-figure

我需要将两个图像添加到matlab图形中并将它们移动到设置路径中。但是当我调整大小时,我的图像会加载完整的大小,只是像素化它,当我尝试移动它时它会失败。继承我的代码:

close all
clc
clear all

fh = figure;
bgh = uibuttongroup('Parent',fh,'Title',...
    'John''s Animation','Position',[.1 .2 .8 .6]);
set(bgh,'FontName','Trebuchet MS','FontSize',15)
rbh1 = uicontrol(bgh,'Style','radiobutton','String','START CAR!',...
    'Units','normalized','Position',[.1 .6 .3 .2]);
rbh2 = uicontrol(bgh,'Style','radiobutton','String','STOP!',...
    'Units','normalized','Position',[.1 .4 .3 .2]);
set(rbh1,'FontName','Trebuchet MS', ...
    'FontSize',15,'ForegroundColor','r')
set(rbh2,'FontName','Trebuchet MS', ...
    'FontSize',15,'ForegroundColor','g')

% axis ([2 1 2 1])
axis square off
car = imread('car.jpg');
carg = rgb2gray(car);
% carg = imresize(car,1);
h = imshow(carg);

steps = linspace(0,2,1000);

set(rbh1,'CallBack','for i = 1:200, set(h,''XData'',steps(i)),pause(0.0001),end')

1 个答案:

答案 0 :(得分:2)

This link应该有帮助。