フィルターのクリア

Returning the "column" number of a Button Down function on an image (GUIDE)

1 回表示 (過去 30 日間)
Jason
Jason 2020 年 1 月 15 日
コメント済み: Jason 2020 年 1 月 15 日
Hello. I have an image loaded onto an axes component in GUIDe and I want the mouse location over the squares to drive an xystage to a positon
All I need to return is which column is selected when the mouse if over a particular square: i.e just considering 1D (i.e. columns), if after pressing the mouse, the x coordinate is between 13 & 39, then report column1 (or just 1). If the x coordinate is between 88 and 114, then report back 3. In reality I have 12 columns so am looking a) for the best way to do this, and b) the best way to define the edges (the values of which I have)
This is my mouse click function
function mouse3Callback(src, eventData)
handles = guidata(src);
axesHandle=get(src,'Parent'); %Object handle is the image
xyz=get(axesHandle,'CurrentPoint');
x = round(xyz(1,1))
y = round(xyz(1,2))
that I assign to the axes holding the image (axes3) Button down fucntion:
set(handles.axes3, 'ButtonDownFcn', @mouse3Callback),
Thnaks for any help
  1 件のコメント
Jason
Jason 2020 年 1 月 15 日
i've come with this, maybe there is a better way:
LE=[15,62,109,157,204,251,298,345,391,438,484,531] %Left egde
RE=LE+32 %Right Edge
col=0;
for i=1:12
if (x>LE(i)&&x<RE(i))
col=i
end
end
col
set(handles.editPt,'String',num2str(col))

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by