Matlab - 如何在黑色全屏上绘制像素?

发布于 2024-12-05 11:44:35 字数 54 浏览 1 评论 0原文

我希望 matlab 向我显示全黑的全屏,并且能够在其上设置像素。

有可能吗?

I want matlab to show me a full screen, all black, and to be able to set pixels on it.

Is it even possible?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

不离久伴 2024-12-12 11:44:35

使用纯 MATLAB 代码无法完全做到这一点。在 Windows 上,我尝试了不同的组合,但任务栏仍然位于顶部(带有“开始”按钮的任务栏):

%# 1)
sz = get(0, 'ScreenSize');
figure('Menubar','none', 'WindowStyle','modal', ...
    'Units','pixels', 'Position', [0 0 sz(3) sz(4)])

%# 2)
figure('Menubar','none', 'Units','normalized', 'Position',[0 0 1 1])

%# 3)
hFig = figure('Menubar','none', 'Units','normalized', 'Position',[0 0 1 1]);
set(hFig, 'Units','pixels')
p = get(hFig, 'Position');
set(hFig, 'Position', [1 31 p(3) p(4)-8]);

您必须编写一个 MEX 函数并直接调用 Win32 API。幸运的是,FEX 上应该已有提交实现此类功能。


这是创建全屏图形并用鼠标绘制点的示例。我正在使用 Jan Simon 的 WindowAPI 解决方案

%# open fullscreen figure
hFig = figure('Menubar','none');
WindowAPI(hFig, 'Position','full');

%# setup axis
axes('Color','k', 'XLim',[0 1], 'YLim',[0 1], ...
    'Units','normalized', 'Position',[0 0 1 1], ...
    'ButtonDownFcn',@onClick)

回调函数:

function onClick(hObj,ev)
    %# draw point
    p  = get(hObj,'CurrentPoint');
    line(p(1,1), p(1,2), 'Color','r', 'LineStyle','none', ...
        'Marker','.', 'MarkerSize',40, 'Parent',hObj)
end

You can't totally do that using pure MATLAB code. On Windows, I tried different combinations, but the taskbar will still be on top (the one with the Start button):

%# 1)
sz = get(0, 'ScreenSize');
figure('Menubar','none', 'WindowStyle','modal', ...
    'Units','pixels', 'Position', [0 0 sz(3) sz(4)])

%# 2)
figure('Menubar','none', 'Units','normalized', 'Position',[0 0 1 1])

%# 3)
hFig = figure('Menubar','none', 'Units','normalized', 'Position',[0 0 1 1]);
set(hFig, 'Units','pixels')
p = get(hFig, 'Position');
set(hFig, 'Position', [1 31 p(3) p(4)-8]);

You would have to write a MEX function and call the the Win32 API directly. Fortunately, there should be existing submissions on FEX implementing such functionality.


Here is an example of creating a full screen figure, and drawing points with the mouse. I am using the WindowAPI solution by Jan Simon

%# open fullscreen figure
hFig = figure('Menubar','none');
WindowAPI(hFig, 'Position','full');

%# setup axis
axes('Color','k', 'XLim',[0 1], 'YLim',[0 1], ...
    'Units','normalized', 'Position',[0 0 1 1], ...
    'ButtonDownFcn',@onClick)

The callback function:

function onClick(hObj,ev)
    %# draw point
    p  = get(hObj,'CurrentPoint');
    line(p(1,1), p(1,2), 'Color','r', 'LineStyle','none', ...
        'Marker','.', 'MarkerSize',40, 'Parent',hObj)
end
静若繁花 2024-12-12 11:44:35

查看心理物理学工具箱。它完全可以满足您的需求,甚至更多。

Check out psychophysics toolbox. It does exactly what you are looking for and more.

别在捏我脸啦 2024-12-12 11:44:35

试试这个:

screen_size = get(0, 'ScreenSize');

buff=zeros(screen_size(3),screen_size(4));

for i=1:50
    buff(screen_size(3)/2-i,screen_size(4)/2+i)=100;

end
f1 = image(buff)
colormap(gray)

set(gcf,'windowstyle','modal');
set(gcf,'OuterPosition', screen_size); 
set(gcf,'position',screen_size); 
set(gcf,'Units','normal', 'outerposition',[0 0 1 1])
set(gca,'Visible', 'Off', 'Position',[0 0 1 1]) 

使用 Alt+F4(或等效键)关闭窗口。我不完全理解为什么你必须这样做,但这是我发现的删除窗框并使绘图扩展全屏的唯一方法。

Try this:

screen_size = get(0, 'ScreenSize');

buff=zeros(screen_size(3),screen_size(4));

for i=1:50
    buff(screen_size(3)/2-i,screen_size(4)/2+i)=100;

end
f1 = image(buff)
colormap(gray)

set(gcf,'windowstyle','modal');
set(gcf,'OuterPosition', screen_size); 
set(gcf,'position',screen_size); 
set(gcf,'Units','normal', 'outerposition',[0 0 1 1])
set(gca,'Visible', 'Off', 'Position',[0 0 1 1]) 

Use Alt+F4 (or equivalent) to kill the window. I don't fully understand why you have to do it this way, but it is the only way I've ever found to remove the window frame and make the plot extend full screen.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文