handle mouse in figure with matlab

hi,I want to select any closed curve in a figure displayed by Matlab and automatically apply an algorithm, that is to say, the call of this algorithm is done automatically after the selection of this zone in closed curve. while waiting for a friendly answer, that you find here my best regards.

Answers (1)

Greg
Greg on 2 Nov 2017
Edited: Greg on 2 Nov 2017
Set the ButtonDownFcn of the plotted object to the algorithm you want to apply. The last line of the algorithm can be to set the callback to empty string so that it only runs the algorithm once, if that is desired behavior.
plot(1:10,'ButtonDownFcn',@myalgorithm);
This will apply to the whole curve, not specific segments of a single curve. Your question was a little ambiguous which way you needed.

3 Comments

thank you for the answer that I have not yet use and verifying its effectiveness, in counterpart my question is not really ambiue except its application. it is simply a matter of selecting a compact pixel number (neighbor to each other and the chosen pixel set is delimited by the closed curve) in a fig displayed via matlab and when the selection of the closed curve is completed to this curve, an automatic call is an algorithm that is already developed as a function or script for the purpose of a particular denoising and using mouse for this case . here and thank you. cordialement.
It could be my ignorance (which I apologize for) of the terminology you're using that is making the question ambiguous to me.
For example (and let's assume a plot of 1:10 counts as a closed curve, even if it doesn't): Are you looking for an algorithm to run if the user clicks anywhere in say 1:3, and a DIFFERENT algorithm to run if the user clicks 4:8? Or should one single algorithm run no matter where the user clicks on the line 1:10?
In the first case, you'd need a logic wrapper as the callback that determines which algorithm to run. In the second case, the algorithm could directly be the callback.
Good Morning, here is an example of a closed curve (attached to this message), supposedly selected by the mouse; what I want to do is to apply an algorithm, automatically (possibly denoising) or after selection between several algorithms (possibly denoising) at all the points that are in the closed curve, including the points of contours ( suppose for example that I have a regular shape, a circle, so I'm going to apply this algorithm to the disc delimited by the circle), I guess it's pretty clear now. thank you, sincerely.

Sign in to comment.

Categories

Asked:

on 2 Nov 2017

Commented:

on 7 Nov 2017

Community Treasure Hunt

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

Start Hunting!