필터 지우기
필터 지우기

How to store resize images into new directory?

조회 수: 12 (최근 30일)
anu
anu 2016년 12월 1일
댓글: Image Analyst 2022년 12월 13일
When I resize single image and store into new directory, it is working properly
filename='E:\img\xyz.jpg';
im = imread('E:\img\xyz.jpg');
k=imresize(im,[300,300]);
imwrite(k,'E:/Resizeimage/aa.jpg','jpg');
But when I resize all images from one directory and try to store into new directory, it is not working properly. I am posting here code. Can anybody tell me what is the problem?
srcFiles = dir('E:\img\*.jpg'); % the folder in which ur images exists
for i = 1 : length(srcFiles)
filename = strcat('E:\img\',srcFiles(i).name);
im = imread(filename);
k=imresize(im,[300,300]);
nm= 'E;/Resizeimage/';
nm1='srcFiles(i).name';
strcat(nm,nm1);
imwrite(k,nm,'jpg');
end
  댓글 수: 6
SUJIT KRISHNANKUTTY
SUJIT KRISHNANKUTTY 2021년 6월 15일
Thank you, it helped me too!!
Luqmaan Ahmad Zaidi
Luqmaan Ahmad Zaidi 2022년 12월 13일
Thank you!

댓글을 달려면 로그인하십시오.

채택된 답변

anu
anu 2017년 12월 21일
편집: Walter Roberson 2017년 12월 21일
srcFiles = dir('E:\img\*.jpg'); % the folder in which ur images exists
for i = 1 : length(srcFiles)
filename = strcat('E:\img\',srcFiles(i).name);
im = imread(filename);
k=imresize(im,[300,300]);
newfilename=strcat('E:\img\',srcFiles(i).name);
imwrite(k,newfilename,'jpg');
end
  댓글 수: 6
Dibyalekha Nayak
Dibyalekha Nayak 2022년 9월 6일
As I am trying to execute this code but i am getting an error like,you may not have read and write permission.
Image Analyst
Image Analyst 2022년 12월 13일
@Dibyalekha Nayak what is your source and destination folders? You cannot rename or copy anything under the c:\Program Files folder in Windows. Also, if one of the source or destination files is open in another program, it may be locked and you may not have permission to do anything in MATLAB with it.
Start your own thread with your script attached.
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Convert Image Type에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by