How to detect left mouse clicks within an area of an image
3 ビュー (過去 30 日間)
古いコメントを表示
ErikJon Pérez Mardaras
2021 年 7 月 18 日
コメント済み: ErikJon Pérez Mardaras
2021 年 7 月 18 日
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:
h=0;
n=0;
imshow('immage.png')
axis off
hold on
pointA=[200,145];
pointB=[210,159];
pointC=[300,162];
plot(pointA(1),pointA(2),'ro');
plot(pointB(1),pointB(2),'ro');
plot(pointC(1),pointC(2),'ro');
Which results in the following:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/688073/image.png)
How can I achieve that? I have been searching but I didn`t find anything
Thank you very much
0 件のコメント
採用された回答
Image Analyst
2021 年 7 月 18 日
Did youi try to use drawpoint()?
Try my attached demo that counts the number of points a user clicks on.
2 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Convert Image Type についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!