Info
この質問は閉じられています。 編集または回答するには再度開いてください。
applying impyramid to many images and saving then seperately
1 回表示 (過去 30 日間)
古いコメントを表示
Hello i have a image data and i want to appyl impyramid to all these images and save them in different folder, here is the code i wrote, my question is how to make is shorter so it wont take too long time for process.
srcFiles = dir('C:\Users\mstfy\Desktop\Matlab\alex\aadeneme\*.jpg');
for i = 1 : length(srcFiles)
filename = strcat('C:\Users\mstfy\Desktop\Matlab\alex\aadeneme\',srcFiles(i).name);
im = imread(filename);
k = impyramid(im, 'reduce');
j = impyramid(k,'reduce');
m = impyramid(j,'reduce');
l = impyramid(im,'expand');
n = impyramid(l,'expand');
v = impyramid(n,'expand');
newfilename=strcat('C:\Users\mstfy\Desktop\Matlab\alex\aadeneme1\',srcFiles(i).name);
newfilename1=strcat('C:\Users\mstfy\Desktop\Matlab\alex\aadeneme2\',srcFiles(i).name);
newfilename2=strcat('C:\Users\mstfy\Desktop\Matlab\alex\aadeneme3\',srcFiles(i).name);
newfilename3=strcat('C:\Users\mstfy\Desktop\Matlab\alex\aadeneme1a\',srcFiles(i).name);
newfilename4=strcat('C:\Users\mstfy\Desktop\Matlab\alex\aadeneme2a\',srcFiles(i).name);
newfilename5=strcat('C:\Users\mstfy\Desktop\Matlab\alex\aadeneme3a\',srcFiles(i).name);
imwrite(k,newfilename,'jpg');
imwrite(j,newfilename1,'jpg');
imwrite(m,newfilename2,'jpg');
imwrite(l,newfilename3,'jpg');
imwrite(n,newfilename4,'jpg');
imwrite(v,newfilename5,'jpg');
end
0 件のコメント
回答 (1 件)
Raunak Gupta
2020 年 3 月 20 日
Hi,
Since it is required to store all the jpg file generated from successive impyramid expansion and reduction, in my opinion I don’t see further optimization rather than using parfor instead of for loop for speeding up the code. Since images are independent of each other the parfor will provide speed up based on the number of workers/CPU Cores available in your device. Note that for using parfor you need to have Parallel Computing Toolbox installed.
0 件のコメント
この質問は閉じられています。
参考
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!