上次讲的是通过ginput函数进行GUI中图像坐标的获取,但是该方法存在很多缺点,如美观、可以获取图像外部区域等问题。今天,我将介绍一个较ginput函数较好的GUI上图像坐标获取函数:datacursormode函数。
今天介绍的函数datacursormode其实是图窗上数据游标模式的启用函数,详细使用方式见MATLAB帮助文档:
其实数据游标模式大家肯定经常见,下面就是这种模式打开的状态:
图像上面会显示游标所在点的一个信息。
下面的Gif图就是使用datacursor函数获取图像坐标的GUI:
下面是实现代码:
function varargout = Getposition2(varargin)
% GETPOSITION2 MATLAB code for Getposition2.fig
% GETPOSITION2, by itself, creates a new GETPOSITION2 or raises the existing
% singleton*.
%
% H = GETPOSITION2 returns the handle to a new GETPOSITION2 or the handle to
% the existing singleton*.
%
% GETPOSITION2('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in GETPOSITION2.M with the given input arguments.
%
% GETPOSITION2('Property','Value',...) creates a new GETPOSITION2 o