Hi,
As per my understanding you want to resize the images present in multiple folders to a new fixed size of 100x100x50.
Since I do not have a sample image of the given dimensions, I will be demonstrating the resizing using a RGB image. You can use the below code to find the images in sub-folders and resize them.
currentWorkingDirectory = pwd;
files = dir(currentWorkingDirectory);
dirFlags = [files.isdir];
foldersList = files(dirFlags);
folderNames = {foldersList(3:end).name};
for i = 1 : length(folderNames)
folderPath = currentWorkingDirectory + "\" + folderNames{i};
subFolder = dir(folderPath);
dirFlags = [subFolder.isdir];
imageList = subFolder(~dirFlags);
imagesNames = {imageList.name};
for j = 1 : length(imagesNames)
imgPath = folderPath + "\" + imagesNames{j};
Iresize = imresize(I,[100 100]);
imwrite(Iresize,currentWorkingDirectory+"\"+"resizeImages\"+folderNames{i}+"_"+imagesNames{j});
For using 3-D volumetric intensity image you can use the following functions:
- Read using niftiread
- Write using niftiwrite
- Resize them using imresize3