How to retrieve image from axes1 and then load it into another axes by using pushbutton.

4 views (last 30 days)
im having two push buttons and two axes. when i press 1st button the selected image will be displayed on axes1 its fine.now how can i do on 2nd button press to show image on 2nd axes.
% code
endfunction pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global filename
[filename, pathname] = uigetfile('','Select Image');
axes(handles.axes1);
input=imread(fullfile(pathname, filename));
imshow(input);
function pushbutton2_Callback(hObject, eventdata, handles)
% code

Accepted Answer

Image Analyst
Image Analyst on 1 Nov 2015
You can try this:
image1 = get(handles.axes1, 'CData');
imshow(image1, 'Parent', handles.axes2);
  1 Comment
Walter Roberson
Walter Roberson on 1 Nov 2015
That requires a correction as axes do not have CData
imh = findobj(handles.axes1, 'type', 'image');
image1 = get(imh, 'CData');
imshow(image1, 'Parent', handles.axes2);
The effect is to copy the image to the second axes. If you want to move the image out of the first axes and into the second axes, then you would use
imh = findobj(handles.axes1, 'type', 'image');
set(imh, 'Parent', handles.axes2);

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!