2

Can I show 3-4 outputs(graphical output, Same images) in different windows using matlab.some thing like the following fig.

for more clarification- example-

for i=1:10 
vid = videoinput('winvideo', 2);
set(vid,'FramesPerTrigger',2);
start(vid);
imageData=getdata(vid,1);
I=rgb2gray(imageData);
figure,imshow(I);
end

In this case 10 frames will be shown in 10 different figure. Which I do not want to do. I want to show all the frames in same window, even if the frame changes every time. enter image description here

I am not talking about figure or subfigure. And the output can be changed every time in the same window.

Regards,

MMH
  • 1,676
  • 5
  • 26
  • 43
  • What do you mean by "output"? Graphical output or command-style output? – marsei Aug 26 '13 at 09:00
  • graphical output. Same images – MMH Aug 26 '13 at 09:05
  • Not sure you can achieve that without referring to figures (figures are windows). One way is to create a figure that fits your entire screen, and have 4 panels in it. – marsei Aug 26 '13 at 09:12
  • Yeah I know, figures are window, but every time the output is changed it is displayed in a new figure. – MMH Aug 26 '13 at 09:23

2 Answers2

2

You can call an already created figure using the simple code figure(h). With this, no new figure window is created.

h = figure; %create figure
...
figure(h); %call the figure h and draw in it.

Using your code

h = figure;

for i=1:10   
  vid = videoinput('winvideo', 2);  
  set(vid,'FramesPerTrigger',2);  
  start(vid);  
  imageData=getdata(vid,1);  
  I=rgb2gray(imageData);  

  figure(h);

  imshow(I);  
end  
marsei
  • 7,691
  • 3
  • 32
  • 41
  • hi, what if I want to make multiple windows as I asked in the original fig?? – MMH Aug 27 '13 at 06:31
  • 1
    Hi- you can declare several of them like `h1 = figure; h2 = figure; ...; figure(h1) ...`. You can also set the figure's position using [this matlab link](http://www.mathworks.com/help/matlab/creating_plots/positioning-figures.html) – marsei Aug 27 '13 at 07:33
  • hi I have a similar question here http://stackoverflow.com/questions/18503494/output-positins-of-matlab-figures you might help me out – MMH Aug 29 '13 at 06:14
1

The closest one can (probably) come to creating a simple rectangular box with an image and no title or menu bars is something like the following:

imagesc(randn(50)) % <-- display the image

axis off, set(gca,'Position',[0 0 1 1]), set(gcf,'menubar','none')

As far as I could unearth it is not possible to get rid of the title bar, see for instance this.

edit

Regarding your specific example, you can try imagesc or image, something like this:

hgcf1=figure;
imagesc(randn(50)); hgca1=gca; axis off, set(hgca1,'Position',[0 0 1 1])
set(hgcf1,'units','normalized','Position',[0.1 0.6 0.4 0.3],'menubar','none')

while 1
    pause(0.5)
    imagesc(randn(50)); 
end

If you want to use imshow:

hgcf1=figure;
imshow(randn(50));  hgca1=gca; 
set(hgca1,'Position',[0 0 1 1])
set(hgcf1,'units','normalized','menubar','none')
axis tight off
while 1
    pause(0.5)
    imshow(randn(50)); 
    hgca1=gca;
    set(hgca1,'Position',[0 0 1 1])
    axis tight
end
Buck Thorn
  • 5,024
  • 2
  • 17
  • 27