Filter löschen
Filter löschen

How to store resize images into new directory?

12 Ansichten (letzte 30 Tage)
anu
anu am 1 Dez. 2016
Kommentiert: Image Analyst am 13 Dez. 2022
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 Kommentare
SUJIT KRISHNANKUTTY
SUJIT KRISHNANKUTTY am 15 Jun. 2021
Thank you, it helped me too!!

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

anu
anu am 21 Dez. 2017
Bearbeitet: Walter Roberson am 21 Dez. 2017
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 Kommentare
Dibyalekha Nayak
Dibyalekha Nayak am 6 Sep. 2022
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 am 13 Dez. 2022
@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:

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Convert Image Type finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by