How to detect left mouse clicks within an area of an image

1 view (last 30 days)
Hi everyone,
I am trying to display an image and what I want to do is to record in the variable h if the user clicks within an area of the image (h=1 if the users clicks within that area and h=0 if not) and save in the variable n the number of left-mouse clicks that the user makes within that area.
The image is immage.png and the three points that determine the "area" commented above are: pointA, pointB and pointC
I have the following code:
axis off
hold on
Which results in the following:
How can I achieve that? I have been searching but I didn`t find anything
Thank you very much

Accepted Answer

Image Analyst
Image Analyst on 18 Jul 2021
Did youi try to use drawpoint()?
Try my attached demo that counts the number of points a user clicks on.
ErikJon Pérez Mardaras
ErikJon Pérez Mardaras on 18 Jul 2021
Thank you very much
It can be done like that:
For more information I have checked this site

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!