Filter löschen
Filter löschen

Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

show an image in an AXES a) without outlines and b) can be clicked using ButtonDownFcn

1 Ansicht (letzte 30 Tage)
Salad Box
Salad Box am 26 Apr. 2018
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
Hi, I would like to show an image in the axes in the GUI to achieve two things: a) the image showed has no outlines if I use the command 'image()' rather than 'imshow'; b) the ButtonDownFcn can be activated when I click on the image.
I have two different approaches to achieve a), however these two different approaches one can also achieve b) while the other could not achieve b). I would like to find out why.
Approach 1:
RGB = imread('picture1.jpg');
h = image(RGB);
set(handles.axes1,'xtick',[]);set(handles,axes1,'ytick',[]);* % remove the xtick and ytick
set(handles.axes1,'xcolor,[0.3 0.3 0.3]),set(handles.axes1,'ycolor',[0.3 0.3 0.3]); % set the xcolor and ycolor the same as the background color.
set(h,'hittest','off');
set(handles.axes1,'ButtonDownFcn',@click);
Approach 2:
RGB = imread('picture1.jpg');
set(handles.axes1,'Visible','off','NextPlot','add');
h = image(RGB,'Parent',handles.axes1);
set(h,'hittest','off');
set(handles.axes1,'ButtonDownFcn',@click);
Now both approach 1 and 2 can achieve a) while approach 1 can also achieve b) but approach 2 can't achieve b). In another word, code written in approach 2 does not respond to click, why?
Would anyone know what happened here?
Many thanks!

Antworten (0)

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by