Getting no results from a mouse click when using ButtonDownFcn with imshow

5 ビュー (過去 30 日間)
jack feinberg
jack feinberg 2019 年 3 月 16 日
コメント済み: Jan 2019 年 3 月 19 日
I'm unable to obtain (x,y) coordinates of an image using a mouse click with "imshow". I can do it with "image" but not with "imshow", and I need "imshow". I've seen lots of other posts on this issue, but none of their solutions seem to work, or the discussion is too technical for me.
I have 4 images arranged two by two, and I'm interested in clicking only on the image in subplot (2,2,3). But when I click nothing happens. Apparantly my function "clicky4" is not being called. Here's the relevant section of code:
global x y
.........
Image = single(rgb2gray(FilterRGBImage));
subplot(2, 2, 3);
vv = imshow(Image,'InitialMagnification', 'Fit');
set(vv, 'HitTest','off','PickableParts','none');
% Try to use the mouse to select a pixel
set(gca,'ButtonDownFcn', @clicky4)
And here is my function "clicky4":
function clicky4(gcbo,eventdata,handles)
%This function is supposed to grab the position (x,y) of the mouse upon a click
global x y
v = get(gca,'Currentpoint');
hold on
x = v(1,1);
y = v(1,2);
end
Any suggestions will be much appreciated. I'm a relative beginner at this stuff....

回答 (1 件)

Image Analyst
Image Analyst 2019 年 3 月 16 日
Would ginput(1) or impixelinfo help you?
  8 件のコメント
jack feinberg
jack feinberg 2019 年 3 月 17 日
Yup. That was the problem; my @function was stored inthe wrong location. A beginner's mistake! Thanks. It all works now!
Jan
Jan 2019 年 3 月 19 日
@jack feinberg: Please use flags only to inform admins and editors about contents, which might conflict with the terms of use, but not to post a comment. Thanks.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeRed についてさらに検索

タグ

製品


リリース

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by