我正在为图像注册编写代码,我想保存固定的Image(handles.imgFixed)并将Image(handles.imgMoving)移动到MATLAB工作区。这样我计划使用evalin将这些变量带回MATLAB GUI进行进一步分析。这是我的GUI代码:
function uploadFixed_Callback(hObject, ~ , handles)
% hObject handle to uploadFixed (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[filename, pathname] = uigetfile({'*.gif; *.png; *.jpg; *.tif', 'Image Files(*.gif,*.png,*.jpg,*.tif)';'*', 'All files'}, 'File Selector');
set(handles.output,'CurrentAxes',handles.imgFixed);
handles.fixPath = strcat(pathname,filename);
hold off;
imshow(handles.fixPath);
hold on;
set( get(handles.imgFixed,'Children'),'ButtonDownFcn', {@imgFixed_ButtonDownFcn,handles});
set( get(handles.imgMoving,'Children'), 'ButtonDownFcn', {@imgMoving_ButtonDownFcn,handles});
guidata(hObject,handles);
% --- Executes on button press in uploadMoved.
function uploadMoved_Callback(hObject, eventdata, handles)
% hObject handle to uploadMoved (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[filename,pathname] = uigetfile({'*.gif; *.png; *.jpg; *.tif', 'Image Files (*.gif,*.png,*.jpg,*.tif'; '*', 'All Files'}, 'File Selector');
set(handles.output, 'CurrentAxes', handles.imgMoving);
handles.movePath = strcat(pathname,filename);
hold off;
imshow(handles.movePath);
hold on;
set( get(handles.imgFixed,'Children'), 'ButtonDownFcn', {@imgFixed_ButtonDownFcn,handles});
set( get(handles.imgMoving,'Children'), 'ButtonDownFcn', {@imgMoving_ButtonDownFcn,handles});
guidata(hObject,handles);
% --- Executes on mouse press over axes background.
function imgFixed_ButtonDownFcn(hObject, eventdata, handles)
% hObject handle to imgFixed (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.output, 'CurrentAxes', handles.imgFixed);
imshow(handles.imgFixed);
% --- Executes on mouse press over axes background.
function imgMoving_ButtonDownFcn(hObject, eventdata, handles)
% hObject handle to imgMoving (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.output, 'CurrentAxes', handles.imgMoving);
imshow(handles.imgMoving);
谢谢 - 感谢您的时间和建议
答案 0 :(得分:0)
assignin('base', 'imgFixed', handles.imgFixed)
- 导出handle.imgFixed到基础工作区globale imgFixed; imgFixed = handles.imgFixed;
但我不知道我是否完全理解你的问题。为什么要将这些图像存储在工作区中?传递变量的句柄有什么问题?