필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

applying impyramid to many images and saving then seperately

조회 수: 1 (최근 30일)
Mustafa Yildiz
Mustafa Yildiz 2020년 3월 17일
마감: MATLAB Answer Bot 2021년 8월 20일
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

답변 (1개)

Raunak Gupta
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.

이 질문은 마감되었습니다.

제품

Community Treasure Hunt

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

Start Hunting!

Translated by