matlab - How to make ginput confine to current axes for selecting a seed point -
i attaching sample gui codes, has 2 axes 2 images , when use ginput select seed point able select on either axes, there anyway limit ginput specific axes
% --- executes on button press in open. function open_callback(hobject, eventdata, handles) % hobject handle open (see gcbo) % eventdata reserved - defined in future version of matlab % handles structure handles , user data (see guidata) global img1; global img2; img1 = imread('peppers.png'); img2 = imread('rice.png'); axes(handles.axes1); imshow(img1,[]); axes(handles.axes2); imshow(img2,[]); % --- executes on button press in seedpointselect. function seedpointselect_callback(hobject, eventdata, handles) % hobject handle seedpointselect (see gcbo) % eventdata reserved - defined in future version of matlab % handles structure handles , user data (see guidata) global img1; global img2; global x; global y; axes(handles.axes1); imshow(img1,[]); [y,x] = ginput(handles.axes1); y = round(y); x = round(x); set(handles.xcord,'string',num2str(x)); set(handles.ycord,'string',num2str(y)); any on limiting ginput specific axes,
thanks, gopi
don't use ginput, create mouse click callback instead (buttondownfcn). can set callback to, example, remove callback function axis. in main program, sets callback, waitfor property change. user clicks, control back, , can read location of last mouse click (currentpoint). note position read out in axis coordinates, not screen pixels. thing, corresponds pixel in image displayed.
Comments
Post a Comment