Using Parpool in splitting the TIFF stack as individual files.
Show older comments
I am using this code to split .tif stack in individual files. Due to large size of those files, it is taking too long to process. Can someone please suggest if I can use papool in this program to distribute the load and speed up the program. Or can you suggest any other way to optimize the speed?
[movieFileList, moviePath] = uigetfile('*.tif','Select TIFF Stack File',...
'MultiSelect', 'on', '/Volumes/Work/');
if ischar(movieFileList)
nFile = 1;
else
nFile = size(movieFileList,2);
end
for iFile = 1:nFile
try
currentMovieName = cell2mat(movieFileList(iFile));
catch
currentMovieName = movieFileList;
end
outputFolderName = erase(currentMovieName, '.tif');
outputFolder = fullfile(moviePath, outputFolderName);
if exist (outputFolder,'dir') > 0
rmdir(outputFolder, 's')
end
mkdir(outputFolder);
currentMovie = fullfile(moviePath, currentMovieName);
frames = tiffread(currentMovie);
nFrame = size(frames,2);
for iFrame = 1:nFrame
currentMovieName = erase(currentMovieName, '.tif');
fileName = [currentMovieName, '_',sprintf('%04d',iFrame),'.tif '];
outputFile = fullfile(outputFolder, fileName);
saveastiff(frames(iFrame).data, outputFile);
end
end
Answers (0)
Categories
Find more on Parallel Computing Fundamentals in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!