Draw a rectangle on an image in gui on mouse hover
This question has two parts. First I want to draw a rectangle on an image in gui only when the mouse hovers on the image. Secondly, if the user clicks the image, clicking should execute a set of statements or a function. Right now, I can only draw the rectangle on the image in following manner,
function slider1_Callback(hObject, eventdata, handles) % hObject handle to slider1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % maxSliderValue = get(handles.slider1, 'Max') % minSliderValue = get(handles.slider1, 'Min') % theRange = maxSliderValue - minSliderValue % steps = [1/theRange, 10/theRange] % set(handles.slider1, 'SliderStep', steps); set(handles.slider1, 'BackgroundColor',[1,1,1]); set(handles.slider2, 'BackgroundColor',[.9,.9,.9]); set(handles.slider1, 'Value', round(hObject.Value)); axes(handles.axes1) matlabImage = imread('image.tif'); image(matlabImage) axis image axis off
This is under slider control, later when I will change the slider the image in the figure will change but I can do this. Its not a problem.
For example this function should be executed when user clicks the image
Thank you for your support.
Note: Mouse hovers means, mouse on image, draw rectangle on image, mouse not on image no rectangle.