2017-01-18 76 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