フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

how to convert the format of images from '.jpg' to '.tif' format. Images are stored in a folder

1 回表示 (過去 30 日間)
preet
preet 2013 年 7 月 23 日
i have a folder with 5000 images from '00001art.jpg' to '05000art.jpg'. i want to convert these all images from '.jpg' format to '.tif' format.
help me please its urgent

回答 (2 件)

Narges M
Narges M 2013 年 7 月 23 日
編集済み: Narges M 2013 年 7 月 23 日
filenames = ls([path '*.jpg']);
for i=1:size(filenames ,1)
this = strtrim(filenames (i,:));
temp = imread([path this]);
this = this(1:end-4);
imwrite(temp,[path this '.tiff'],'tiff');
end
  2 件のコメント
Jan
Jan 2013 年 7 月 23 日
Using dir directly is much more efficient than parsing the output of ls, which write the results from dir to a string.
List = dir(fullfile(folder, '*.jpg'));
Name = {List.name};
preet
preet 2013 年 7 月 29 日
jan simon plz write the exact code what should i do

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 7 月 23 日
folder='D:/Matlab/' ;% For example
f=dir([folder '*.jpg']);
for k=1:numel(f)
old_file=f(k).name;
new_file=strrep(old_file,'jpg','tif')
im=imread([folder old_file])
imwrite(im,[folder new_file])
end

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by