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

2 次查看(过去 30 天)
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

采纳的回答

Image Analyst
Image Analyst 2015-11-1
You can try this:
image1 = get(handles.axes1, 'CData');
imshow(image1, 'Parent', handles.axes2);
  1 个评论
Walter Roberson
Walter Roberson 2015-11-1
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);

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Geometric Transformation and Image Registration 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by