필터 지우기
필터 지우기

how to rename and save the result of image in the gui?

조회 수: 1 (최근 30일)
Manoj Kumar
Manoj Kumar 2014년 4월 28일
댓글: Image Analyst 2014년 5월 1일
%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...

채택된 답변

Image Analyst
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
Manoj Kumar
Manoj Kumar 2014년 5월 1일
The code is working well when I save the image using save push button for one time. But when I try to save another image second time, it is getting overwritten on the first image that I saved. I am loosing the first image. Can you please help me.
Thanks...
Image Analyst
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 CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by