how to rename and save the result of image in the gui?
1 次查看(过去 30 天)
显示 更早的评论
%Input file name is TOPGAL.jpg and i am converting it into grayscale:
%i am doing this with the help of push buttons in the GUI.
%input file - push button 1
axes(handles.axes1);
global im
[filename,pathname]=uigetfile('*'); % read the input image
im=imread([pathname,filename]);
%oupufile - push button 2
axes(handles.axes2);
im1=rgb2gray(im);
"" now how to save the output image with the name as TOPGAL_gray.jpg("original file name"_gray.jpg) directly without need to type it again"
THANKS...
0 个评论
采纳的回答
Image Analyst
2014-4-28
编辑:Image Analyst
2014-4-28
Try this:
[baseFileName, folder]=uigetfile('*') % read the input image
% other code.....
% Now save as jpg format.
[~, baseFileName, extension] = fileparts(baseFileName);
outputBaseFileName = sprintf('%s_gray.jpg', baseFileName);
outputFullFileName = fullfile(folder, outputBaseFileName)
imwrite(im1, outputFullFileName);
3 个评论
Image Analyst
2014-5-1
What gets reported to the command window for baseFileName? If you selected a different folder, then baseFileName will be different and then outputBaseFileName will also be different. Check to see that they are different.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 MATLAB Report Generator 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!