2017-01-18 34 views
1

我想单击/双击图像并开始impoly。 喜欢的东西:交互式鼠标点击MATLAB GUI中的图像区域

if(user perform 'doubleclick' on the image in image area (matlab gui)) 
    % polygon start to create 
    bw = impoly... 
end 

我想图像(一个接一个)上创建更多的多边形。

+0

可否请你添加更多的信息,并上传你手头的问题的代码?因为这是你的问题很难理解。 – buzjwa

+0

已更新。 –

+0

使用'impoly'是个好主意。发布你现在的解决方案,并解释你的问题。学习如何使用'ButtonDownFcn' [坐标轴属性](https://www.mathworks.com/help/matlab/ref/axes-properties.html)。 – buzjwa

回答

2

您通常可以使用图像对象的ButtonDownFcn来检测任何鼠标与图像的交互。然后,您可以(即回调中)检查父图的SelectionType属性,以确定它是什么类型的点击

h = imshow(rand(100)); 

% Setup callback function for mouse events on the image 
set(h, 'ButtonDownFcn', @my_callback) 

function my_callback(src, evnt) 

    % Get the selection type 
    type = get(gcbf, 'SelectionType'); 

    % If it was a double click.... 
    if strcmpi(type, 'open') 
     bw = impoly(...); 
    end 
end