Unable to save image using a SAVE button
Mostrar comentarios más antiguos
I have created a matlab GUI where I want to save the processed images using a SAVE button. I am using a slider where I can browse through the processed images. I want to save each image with the SAVE button. Unfortunately, the images are not saved in the correct format(I want to save it in the jpeg format). Any suggestions would be appreciated.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles = guidata(hObject);
filePattern=handles.filePattern;
num_files=handles.num_files;
theFiles=handles.theFiles;
myFolder=handles.myFolder;
value=handles.value;
seg=handles.seg;
% dirName = fullfile(pwd,'Results',myFolder);
% if ~exist(dirName,'dir')
% mkdir(dirName);
% end
[filename, foldername] = uiputfile('D:\regionGrowing_MLT');
complete_name = fullfile(foldername, filename);
imwrite(seg{value}, complete_name,'jpg');
guidata(hObject, handles);
end
6 comentarios
Geoff Hayes
el 14 de Mayo de 2021
Warid - what format are the files being saved as? Are you sure that you are saving the correct image to file? I'm assuming that seg is a cell array of each of the images that you are cycling through.
Warid Islam
el 14 de Mayo de 2021
Walter Roberson
el 14 de Mayo de 2021
I recommend that you configure to show file extensions; https://fileinfo.com/help/windows_10_show_file_extensions
Warid Islam
el 14 de Mayo de 2021
Walter Roberson
el 15 de Mayo de 2021
The implication is that when you do the [filename, foldername] = uiputfile('D:\regionGrowing_MLT'); that the user is giving you a name without any file extension, and you are not appending an extension.
Your file j should be a jpeg file, considering the way you created it.
Warid Islam
el 15 de Mayo de 2021
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Convert Image Type en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
