Filter löschen
Filter löschen

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

1 Ansicht (letzte 30 Tage)
Jason
Jason am 15 Jan. 2020
Kommentiert: Jason am 15 Jan. 2020
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 Kommentar
Jason
Jason am 15 Jan. 2020
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))

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by