Prev: Changing Default Stream within Simulink for generating random numbers
Next: PCI_QUAD04 random spikes in reading
From: shaaneahmed Raza on 28 Apr 2010 18:39 HI, I am working on a GUI. What I want to do is to click the image and display some text on that location in the image; The ButtonDownFcn does not work with imshow command The same code works if I replace imshow with imagesc command. The code is given below. i=imread('cameraman.tif'); handles.input=im2double(i); axes(handles.input_axes); a = get(gca,'ButtonDownFcn'); h = imshow(handles.input,'Parent',gca); set(h,'HitTest','off'); set(gca,'ButtonDownFcn',a); In the ButtonDownFcn I have the following code a = get(gca,'CurrentPoint' ); text(a(1,1),a(1,2),'A');
From: Matt Fig on 28 Apr 2010 19:01
I don't have the IPT, but if I had to guess I would say you should be setting the buttondownfcn to the image object, not the axes. For example, this works: function [] = image_prob() X = load('clown'); IM = ind2rgb(X.X,X.map); h = image(IM,'Parent',gca); %Also with: h = imagesc(IM,'Parent',gca); set(h,'ButtonDownFcn',{@ax_bdfcn}); function [] = ax_bdfcn(varargin) a = get(gca,'CurrentPoint' ); text(a(1,1),a(1,2),'A'); |