필터 지우기
필터 지우기

Is there any way to save my processed Images into different folders?

조회 수: 2 (최근 30일)
Bajdar Nouredine
Bajdar Nouredine 2022년 12월 25일
댓글: Karim 2022년 12월 25일
I applied pre processing filters on 4 different set of images each one contains 10 images, I want to save them in 4 different folders after processing

채택된 답변

Karim
Karim 2022년 12월 25일
편집: Karim 2022년 12월 25일
Yes this is possible, below you can find some pseudo code showing the logic behind the process.
Hope it helps.
EDIT: updated the pseudo code after the comments of the OP
% create a list of the folders, note the " --> we want these to be strings
InputFolders = [ "C:\Users\96475\OneDrive\Desktop\new article\archive\Testing\glioma\";
"C:\Users\96475\OneDrive\Desktop\new article\archive\Testing\meningioma\";
"C:\Users\96475\OneDrive\Desktop\new article\archive\Testing\notumor\";
"C:\Users\96475\OneDrive\Desktop\new article\archive\Testing\pituitary\"];
OutputFolders = [ "C:\Users\96475\OneDrive\Desktop\new article\archive\Testing\out_1\";
"C:\Users\96475\OneDrive\Desktop\new article\archive\Testing\out_2\";
"C:\Users\96475\OneDrive\Desktop\new article\archive\Testing\out_3\";
"C:\Users\96475\OneDrive\Desktop\new article\archive\Testing\out_4\"];
% loop over the folders
for f = 1:numel(InputFolders)
% do some processing
count=1;
imagelist = dir( InputFolders(f) );
num = numel(imagelist);
imdata = cell(1,numel(imagelist));
% loop over the files in the folder
for k = 3:num
% get the image name
fname = imagelist(k).name;
% generate the full name to load the image
sss = InputFolders(f) + string(fname);
% load the image
curr_image = imread(sss);
% process the image
processed_image = imagepreprocessing(curr_image);
% loop over the output folders
for o = 1:numel(OutputFolders)
% generate the full name to save the image
ooo = OutputFolders(o) + string(fname)
% save the image
imwrite(image, ooo)
end
% increase the overal counter
count = count + 1;
end
end
  댓글 수: 3
Bajdar Nouredine
Bajdar Nouredine 2022년 12월 25일
@Karim I want to save imgpreprocessed{k-2} in different 4 folders just like input folders with different names
Karim
Karim 2022년 12월 25일
@Bajdar Nouredine, i've updated the answer using your demo code to demonstrate the idea.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Biomedical Imaging에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by