resize subplot
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
this is my code,I want to resize picture who play the video, the mean is subplot could be resize, don't see small.
I have no idea how to do.
pleas give me some advices. Thanks!!
function f2()
clear all;
obj1 = mmreader('phone.avi');
obj2 = mmreader('can.avi');
%obj3 = mmreader('book.avi');
%obj4 = mmreader('phone.avi');
vid1 = read(obj1);
vid2 = read(obj2);
%vid3 = read(obj3);
%vid4 = read(obj4);
frame1 = 1;
frame2 = 50;
% frame3 = 30;
% frame4 = 1;
f4 = 1;
hst1=0;
hst2=0;
% hst3=0;
% hst4=0;
h = figure('Name','Video ', 'NumberTitle','off','Color',[1,1,1],'Toolbar','none','Visible','on', 'Position',[30 40 1000 700],...
'Resize','on','menu','none');
hstat1 = uicontrol('unit','pixel','style','checkbox','value',0,'position',...
[50 530 25 25],'units','normalized');
hstat2 = uicontrol('unit','pixel','style','checkbox','value',0,'position',...
[50 450 25 25],'units','normalized');
% hstat3 = uicontrol('unit','pixel','style','checkbox','value',0,'position',...
% [50 480 25 25]);
% hstat4 = uicontrol('unit','pixel','style','checkbox','value',0,'position',...
% [50 410 25 25]);
hplay1 = uicontrol('unit','pixel','style','pushbutton','string','藥罐_PLAY',...
'position',[50 530 70 40],'backgroundColor',[0.3,0.7,1],'units','normalized','callback',{@play1_callback});
hplay2 = uicontrol('unit','pixel','style','pushbutton','string','手錶_PLAY',...
'position',[50 450 70 40],'backgroundColor',[0.3,0.7,1],'units','normalized','callback',{@play2_callback});
%hplay3 = uicontrol('unit','pixel','style','pushbutton','string','書本_PLAY',...
%'position',[50 480 70 40],'backgroundColor',[0.3,0.7,1],'callback',{@play3_callback});
%hplay4 = uicontrol('unit','pixel','style','pushbutton','string','手機_PLAY',...
%'position',[50 410 70 40],'backgroundColor',[0.3,0.7,1],'callback',{@play4_callback});
hstop1 = uicontrol('unit','pixel','style','pushbutton','string','藥罐_STOP',...
'position',[50 370 70 40],'backgroundColor',[0.2,1,0],'units','normalized','callback',@stop1_callback);
hstop2 = uicontrol('unit','pixel','style','pushbutton','string','手錶_STOP',...
'position',[50 290 70 40],'backgroundColor',[0.2,1,0],'units','normalized','callback',@stop2_callback);
% hstop3 = uicontrol('unit','pixel','style','pushbutton','string','書本_STOP',...
% 'position',[50 170 70 40],'backgroundColor',[0.2,1,0],'callback',@stop3_callback);
% hstop4 = uicontrol('unit','pixel','style','pushbutton','string','手機_STOP',...
% 'position',[50 90 70 40],'backgroundColor',[0.2,1,0],'callback',@stop4_callback);
hexit = uicontrol('unit','pixel','style','pushbutton','string','EXIT',...
'position',[50 210 70 40],'backgroundColor',[1,0,0],'units','normalized','callback',@exit_callback);
while (1)
if hst1==1
%subplot('Position',[left bottom width height])
%subplot(2,1,1,'Position',[0 0 320 240]); imshow(vid1(:,:,:,frame1));
subplot(2,1,1); imshow(vid1(:,:,:,frame1),'InitialMagnification','fit');
%imshow(checkerboard)
%truesize(a,[640 480]);
if frame1 < size(vid1,4)
frame1 = frame1+1;
else
frame1 = 1;
end
end
if hst2==1
subplot(2,1,2); imshow(vid2(:,:,:,frame2));
if frame2 < size(vid2,4)
frame2 = frame2+1;
else
frame2 = 1;
end
end
% if hst3==1
% subplot(2,2,3); imshow(vid3(:,:,:,frame3));
% if frame3 < size(vid3,4)
% frame3 = frame3+1;
% else
% frame3 = 1;
% end
% end
%
% if hst4==1
% subplot(2,2,4); imshow(vid4(:,:,:,frame4));
% if frame4 < size(vid4,4)
% frame4 = frame4+1;
% else
% frame4 = 1;
% end
% else
% subplot(2,2,4); imshow(vid2(:,:,:,1));
%end
drawnow;
if f4 ==10000
break;
% else f4 = f4+1;
end
end
function play1_callback(hObject0,eventdata0)
set(hstat1,'value',1);
hst1=1;
set(hplay1 ,'backgroundColor',[1,1,0],'string','藥罐_播放中');
%set(gcf,'units','normalized','position',[0 0 1 1]);
end
function play2_callback(hObject1,eventdata1)
set(hstat2,'value',1);
hst2=1;
set(hplay2 ,'backgroundColor',[1,1,0],'string','手錶_播放中');
end
% function play3_callback(hObject2,eventdata2)
% set(hstat3,'value',1);
% hst3=1;
% set(hplay3 ,'backgroundColor',[1,1,0],'string','書本_播放中');
% end
% function play4_callback(hObject3,eventdata)
% set(hstat4,'value',1);
% hst4=1;
% set(hplay4 ,'backgroundColor',[1,1,0],'string','手機_播放中');
% end
function stop1_callback(hObject,eventdata)
set(hstat1,'value',0);
hst1=0;
set(hplay1 ,'backgroundColor',[0.3,0.7,1],'string','藥罐_PLAY');
end
function stop2_callback(hObject,eventdata)
set(hstat2,'value',0);
hst2=0;
set(hplay2 ,'backgroundColor',[0.3,0.7,1],'string','手錶_PLAY');
end
% function stop3_callback(hObject,eventdata)
% set(hstat3,'value',0);
% hst3=0;
% set(hplay3 ,'backgroundColor',[0.3,0.7,1],'string','書本_PLAY');
% end
%
% function stop4_callback(hObject,eventdata)
% set(hstat4,'value',0);
% hst4=0;
% set(hplay4 ,'backgroundColor',[0.3,0.7,1],'string','手機_PLAY');
% end
function exit_callback(hObject,eventdata)
f4=1000;
stop1_callback;
close gcf;
end
end
0 comentarios
Respuesta aceptada
Chandra Kurniawan
el 10 de Mzo. de 2012
Hi, Pan
You can use 4 axes and replace command subplot with
imagesc(vid2(:,:,:,frame3),'parent',axeshandle);
This is just small example with images
vid1 = imread('cameraman.tif');
vid2 = imread('peppers.png');
vid3 = imread('pout.tif');
vid4 = imread('football.jpg');
hfig = figure('unit','pixel','position',[100 100 512 512],'menubar','none');
ax1 = axes('parent',hfig,'unit','pixel','position',[0 0 256 256]);
ax2 = axes('parent',hfig,'unit','pixel','position',[257 0 256 256]);
ax3 = axes('parent',hfig,'unit','pixel','position',[0 257 256 256]);
ax4 = axes('parent',hfig,'unit','pixel','position',[257 257 256 256]);
imagesc(vid1,'parent',ax1); colormap(gray); axis(ax1,'off');
imagesc(vid2,'parent',ax2); colormap(gray); axis(ax2,'off');
imagesc(vid3,'parent',ax3); colormap(gray); axis(ax3,'off');
imagesc(vid4,'parent',ax4); colormap(gray); axis(ax4,'off');
3 comentarios
Chandra Kurniawan
el 11 de Mzo. de 2012
Yes, just replace command imagesc(vid1,'parent',ax1); with
imagesc(vid2(:,:,:,frame2),'parent',ax1);
Más respuestas (1)
Image Analyst
el 11 de Mzo. de 2012
Look how I resize the figure and two axes in this demo code:
0 comentarios
Ver también
Categorías
Más información sobre Image Acquisition Toolbox Supported Hardware en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!