matlab gui界面做了一个图像显示的功能,如何把显示图像保存为一个文件

2024年11月30日 11:50
有1个网友回答
网友(1):

做一个保存按钮,Tag是“save”
callback函数如下

% --- Executes on button press in save.
function save_Callback(hObject, eventdata, handles)
% hObject handle to save (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[filename, pathname] = uiputfile({'*.bmp';'*.jpg';'*.png'}, 'Pick an image-file');
if isequal(filename,0) || isequal(pathname,0)
disp('User pressed cancel')
return
else
disp(['User selected ', fullfile(pathname, filename)])
end
imwrite(handles.tempimg,[pathname filename]);%%你要保存的图像的axes名称
guidata(hObject, handles);