Using impixelinfo command

Hi,
I used guide command to create a user interface for my matlab's code. The interface contains 2 axes: axes1 - 3D graph, axes2 - an image. I'm trying to obtain the coordinates of the graph in axes1, when the mouse is on top of it. I was told that I should use the impixelinfo command, but unfortunatly, i didn't managed how to use it.
I will be grateful for a help, Regards

 Accepted Answer

Walter Roberson
Walter Roberson on 3 Mar 2011

0 votes

Which Matlab version are you using? By 2008b at latest, the documentation for impixelinfo says,
IMPIXELINFO(H) creates a pixel information tool in the figure specified by the handle H, where H is an image, axes, uipanel, or figure object. Axes, uipanel, or figure objects must contain at least one image object.
Thus, the function would work for handles.axes2 because that axes contains an image.
To obtain coordinates within axes1 you may wish to activate datacursormode
Alternately, you may wish to set the figure WindowButtonMotionFcn property and have that callback function get() the figure CurrentPoint property and do whatever you need to do with it. If you only need the information upon clicks, use a WindowButtonDownFcn callback.

1 Comment

a
a on 3 Mar 2011
Thank you very much, you help me a lot.
The 'datacursormode' is perfect for me!!
Thanks :)

Sign in to comment.

More Answers (1)

Andreas Goser
Andreas Goser on 27 Feb 2011

0 votes

It is alwas difficult to guess -"i didn't managed how to use it." needs guessing. My guess is that IMPIXELINFO does not find your GUI automtically as the handle is hidden. I suggest using impixelinfo(h).

4 Comments

a
a on 27 Feb 2011
Thanks for your answer.
All my function got automatic parameters: hObject, eventdata, handles, As gotten from the guide command.
I tried to call the command as: impixelinfo(handles.axes1), but the matlab wrote an error message.
Whats wrong with "impixelinfo(handles.axes1)"?
Regards
It is important to know the error message. Error messages are there for a reason.
a
a on 3 Mar 2011
The error is that this function works on images only. I was told that it work on graphs too.
Are you familiar with a similar function that works on graph?
I need a function which retrieve the coordinates of the graph according to the mouse current position.
I'd say you need to "convert" the graph into an image.
> I was told that it work on graphs too.
Well then ask the person who told you ;-)

Sign in to comment.

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!