Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

applying impyramid to many images and saving then seperately

1 Ansicht (letzte 30 Tage)
Mustafa Yildiz
Mustafa Yildiz am 17 Mär. 2020
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
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

Antworten (1)

Raunak Gupta
Raunak Gupta am 20 Mär. 2020
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.

Diese Frage ist geschlossen.

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by