Write an image name to particular folder using imwrite
이전 댓글 표시
Dear users ..
i have been used an bottom in GUI to browse an image from computer .. but when i used imwrite, i can not write that image with its name.. so its not efficient to give name to that image each time .. is there any way to write image with its real name .. thanks
[fname path]=uigetfile('*.*');
if isequal(fname,0) | isequal(path,0)
warndlg('Please select an image from directory ..');
else
fname=strcat(path,fname);
Im2=imread(fname);
imwrite(Im2,'D:\imagefolder','jpeg');
댓글 수: 2
Suvetha Ravi
2020년 1월 25일
Can you give me a code that how can I store the resized and grayscaled images in a separate folder in a drive?Hoping for a reply!
Image Analyst
2020년 1월 25일
Suvetha, yes - I already gave the code to ahmed. It is below - just scroll down or click here. Take note how there are both destinationFolder and folder (which is the input image folder).
Important Note: do not use path as the variable name for the folder like ahmed mistakenly did.
채택된 답변
추가 답변 (2개)
Azzi Abdelmalek
2016년 3월 30일
Use
fname=fullfile(path,fname);
댓글 수: 3
ahmed obaid
2016년 3월 30일
Azzi Abdelmalek
2016년 3월 30일
What error?
Sajanaji
2017년 9월 7일
provide file name before '.jpg'
Akash kumar
2021년 3월 16일
0 개 추천
y = [1,1,1,1,1];
x = [2,2,2,2,2];
z = [2,2,2,2,2];
a = [3,3,3,3,3];
b = [4,4,4,4,4];
c = [5,5,5,5,5];
figure;
h(1)=plot(x,y);
figure;
h(2)=plot(x,z);
figure;
h(3)=plot(x,a);
figure;
h(4)=plot(x,b);
figure;
h(5)=plot(x,c);
for k=1:5
baseFileName = sprintf('figure_%d.png',k);
fullFileName = fullfile(cd,'image', baseFileName); % cd :-> for storing the image in current directory and image:-> is the folder % % name (First you creat the folder on that particular directory)
saveas(gcf,fullFileName);
end
카테고리
도움말 센터 및 File Exchange에서 Manage Products에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!