Simultaneously display image on two monitors
Show older comments
My laptop is connected to two external monitors. I would like an image to appear on each monitor at exactly the same time. When I use this script, the image appears on the monitor for axHandle1 slightly before axHandle2:
figHandle=figure('WindowState', 'fullscreen','MenuBar', 'none', 'ToolBar', 'none','OuterPosition',[4000 0 2560 1440],'color','w');
axHandle1 = axes('Units','normalized','Position',[0 0 1 1],'color','w');
figHandle=figure('WindowState', 'fullscreen','MenuBar', 'none', 'ToolBar', 'none','OuterPosition',[1440 0 2560 1440],'color','w');
axHandle2 = axes('Units','normalized','Position',[0 0 1 1],'color','w');
imshow(rgb1,'Parent',axHandle1);
imshow(rgb2,'Parent',axHandle2);
Answers (1)
Try:
imh(1) = imshow(...., 'Visible','off');
imh(2) = imshow(...., 'Visible','off');
then later:
set(imh, 'Visible','on')
EDIT: Create the figures (or uipanels) with their Visible property set to 'off':
fgh(1) = figure(...., 'Visible','off');
fgh(2) = figure(...., 'Visible','off');
axh(2) = axes(..., 'Parent',fgh(2));
axh(1) = axes(..., 'Parent',fgh(1));
imh(2) = imshow(..., 'Parent',axh(2));
imh(1) = imshow(..., 'Parent',axh(1));
Then, when you want them to both appear simultaneously:
set(fgh, 'Visible','on')
12 Comments
Jessica Yorzinski
on 24 Feb 2019
@Jessica Yorzinski: that is a bit strange and unfortunate, as Visible is clearly listed as a property of the image object:
See my edited answer for another approach using figures. If you want the figures to be visible the entire time, then you can easily do the same thing with uipanel.
Jessica Yorzinski
on 26 Feb 2019
Jessica Yorzinski
on 26 Feb 2019
'When a figure is created, there is a bar that appears on the top of the screen and it says "Figure."'
As far as I can tell you are describing the figure title itself. You can see it when the figure is visible, and you can't see it when the figure is not visible. You can change it by setting the Name property.
"How do you suggest using uipanel instead?"
It is really much the same, just with the extra step of adding uipanels:
- create figures: visible=on.
- add uipanels to figures: visible=off.
- add axes to uipanels
- add images to axes.
- when you a want to, set the uipanels to visible=on.
Why is this useful? Because you can create the uipanels with visible=off and you can add any axes or other child objects that you want to them: any child objects will also be invisible if the parent uipanel is also invisible. Then you only need to change the uipanel to visible=on and all of its child objects will be visible too (assuming that they already have visible=on). Read the uipanel help to know more.
Jessica Yorzinski
on 4 Mar 2019
Stephen23
on 4 Mar 2019
"Unfortunately, I don't think this will quite work."
1. Create two figures with:
- positions equal to your screen sizes (you will find the the graphcis root MonitorPositions property useful).
- set them to have a white background.
2. Add uipanels (visible=off, no title, no border)
3. Add any images to the uipanels
4. Change the uipanels to visible=on when required.
Read the documentation, experiment, and you will actually make some progress. I don't see any reasons why that should not work (I have done many similar GUIs myself, using the visibilty property to show different objects depending on some variable, uicontrol, or timer object).
Jessica Yorzinski
on 6 Mar 2019
(1) You need to add the axes to the uipanel, as I stated in my last comment. You added the axes to the figure, which means the uipanel is totally useless.
(2) Use the graphics root MonitorPositions property as I mentioned in my last comment, and use each row to set the position of one figure. I did not mention using the property fullscreen.
Something like this:
fgh(2) = figure(....);
uih(2) = uipanel(fgh(2), 'Visible','off',...);
axh(2) = axes(uih(2),...); % OR axes(..., 'Parent',uih(2))
imh(2) = imshow(..., 'Parent',axh(2));
Jessica Yorzinski
on 8 Mar 2019
Guillaume
on 8 Mar 2019
I have no idea if you can do anything better than what Stephan suggested, but you have to bear in mind that what you want may not be achievable as you only control the first link of a fairly long chain. To get an image displayed, it goes through:
- matlab
- the java virtual machine
- the OS
- the graphics card
- the monitor panels
Any of these can introduce a jitter over which you have no control.
Categories
Find more on Environment and Settings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!