How can I display a figure in the entrire screen of a second monitor without toolbars/whitespace/greyspace around it?
6 views (last 30 days)
Show older comments
I am trying to project various different sine waves onto a scene using a projector in order to obtain depth information. My current method involves a projector currently acting as my second monitor connected through display port. I'm then trying to fit a figure of the sinewaves to the monitor such that there is nothing around the edges, just the sinewave pattern. The code I have been trying is this:
time = 1:0.001:2;
frequency = 60;
phase = 90;
phase_in_rad = degtorad(phase); %Ignore these for the time being
y=0.5*cos((2*pi*frequency*time)+(2*pi/3));
plot(time,y);
print('SineWaveImage','-djpeg');
fig1 = figure;
imshow(imread('SineWaveImage.jpg'));
pos_fig1 = [0 0 1900 2000];
set(fig1,'Position',pos_fig1,'ToolBar','none','MenuBar','none')
I have been attempting to change pos_fig1 so that the projector projects only the sinewaves and no grey/white space. I've also tried a function that cuts a lot of the white space successfully, but still suffers from the grey space when it is put back into a figure.
Is there a better way of writing this code, or any other methods of achieving this? Thanks for any help
0 Comments
Answers (1)
Karan Singh
on 4 Feb 2025
Edited: Karan Singh
on 4 Feb 2025
You can avoid "print" and "imread" which introducees extra image border. Try using "MonitorPositions" to detect the 2nd monitor and " WindowState = 'fullscreen' " to make the figure cover the intrie projector. Further you can set off the axis lable and resize the figure. Here is my code
time = linspace(0, 2, 2000);
frequency = 60;
phase = 90;
phase_in_rad = deg2rad(phase);
y = 0.5 * cos((2 * pi * frequency * time) + (2 * pi / 3));
fig1 = figure('ToolBar', 'none', 'MenuBar', 'none', 'Color', 'black');
% Move figure to projector screen (modify position based on setup)
monitorPositions = get(0, 'MonitorPositions');
projectorPos = monitorPositions(end, :);
set(fig1, 'Position', projectorPos, 'WindowState', 'fullscreen');
ax = axes(fig1, 'Position', [0 0 1 1], 'XColor', 'none', 'YColor', 'none', 'Color', 'black');
plot(time, y, 'w', 'LineWidth', 2); % White sine wave on black background
axis off; % Remove axis labels and borders
xlim([min(time) max(time)]);
ylim([-1 1]);
% Refresh figure to remove unwanted white space
drawnow;
You can check and see if this resolves the issue.
Karan
0 Comments
See Also
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!