Shi*_*bii 5 matlab user-interface cursor-position mousemove matlab-figure
我似乎无法让我的图像显示鼠标光标的坐标,也可以使用ginput同时存储点.
我目前正在尝试以下方法:
MriHotrod = imread('Image.bmp');
Fig = figure('Name','BobDole'),...
imshow(Image, 'InitialMagnification', 250)
axis on
impixelinfo
Image_1 = ginput(4)
close BobDole
Run Code Online (Sandbox Code Playgroud)
ginput仍然有效,但impixelinfo保持不变
Pixel Info = (X, Y) Pixel Value
Run Code Online (Sandbox Code Playgroud)
我知道一些解决这个问题的方法,但它们涉及到函数.这似乎是一个可以避免使用函数的相当简单的问题.
如果你输入edit ginput并滚动到238-ish行,你会看到
% Adding this to enable automatic updating of currentpoint on the figure
set(fig,'WindowButtonMotionFcn',@(o,e) dummy());
Run Code Online (Sandbox Code Playgroud)
换句话说,在图中ginput设置a WindowButtonMotionFcn.我的猜测也是impixelinfo使用这个函数,所以一旦ginput被调用就会被禁用.
实际上,在impixelinfoval(使用的函数impixelinfo)中,我们在第83行附近找到:
callbackID = iptaddcallback(hFig,'WindowButtonMotionFcn', @displayPixelInfo);
Run Code Online (Sandbox Code Playgroud)
奇怪的是:点击4分后如何重置?
这个魔法是由222-ish线完成的ginput:
initialState.uisuspendState = uisuspend(fig);
Run Code Online (Sandbox Code Playgroud)
显然,uisuspend是一个有点未记录的函数,用于暂停任何预先存在的WindowButton*函数,以便以后重置它们.所以,如果你注释掉这一行
%initialState.uisuspendState = uisuspend(fig);
Run Code Online (Sandbox Code Playgroud)
并保存ginput,并重新做整件事,你看到你想要的行为.
你也会看到为什么这些函数首先被暂停 - 由于我不太明白的原因,当启用两个这样的函数时,一切都变得非常慢.
| 归档时间: |
|
| 查看次数: |
8907 次 |
| 最近记录: |