Optimal strategy for loading in many tiffs and resaving as imageJ tiff stacks
3 次查看(过去 30 天)
显示 更早的评论
Hey there,
I have some large video stored as tiff images (50,000+ frames), save in a folder as a set of individual tiff images. I want to "repackage" these folders so that they contain stacks of 500. I've started to do this using imread, but I am wondering what the fastest way(s) to do something like this are. Thanks!
1 个评论
Geoff Hayes
2014-9-28
Pavlov - are you trying to create a new tiff files (of 500 frames each i.e. you've appended one image after the other using the example at Write Multiple Images to TIFF File), or just move them into separate folders of 500 files each?
采纳的回答
Mohammad Abouali
2014-9-28
编辑:Mohammad Abouali
2014-9-28
Ok, if you are just moving files from one folder to another you can do it at the command prompt, you don't really need matlab. But anyway, let's say you want to do it in matlab.
I am assuming that you are at the folder that your 50k+ frames each stored as a tiff image is stored. And you want to move them to subfolders within the same folder called p1 to pn where p1 stores tiff1 to tiff500, and p2 stores tiff501 to tiff1000 and so on.
Here is the code:
n=500;
fileList=dir('*.tiff');
% NOTE adjust the extension to tif or tiff based on what you have
nFiles=numel(fileList);
nFolders=ceil(nFiles/n);
fileList=struct2cell(fileList);
fileList=fileList(1,:);
for i=1:nFolders
folderName=['p' num2str(i)];
mkdir(folderName);
func=@(x) ( copyfile(x,folderName) );
startFile=(i-1)*n+1;
endFile=min( i*n, nFiles);
cellfun(func,fileList(startFile:endFile));
end
0 个评论
更多回答(1 个)
Image Analyst
2014-9-28
"some large video" is not proper grammar. Do you mean "some large videos" so that there are multiple videos, or do you mean "a large video", like there is only one?
And when you say "save in a folder", do you mean "saved in a folder"? But then the second half of that first sentence is just saying the same thing as the first half, so I'm confused. The best I can guess is that you have multiple videos that are stored not as video files (like .mpg or .avi) but saved as a sequence of individual tiff images. Presumably each sequence has some different name prefix to distinguish between the different videos.
Now define "repackage" into stacks. Do you want to have multi-page tiff images where each tiff image has 500 images (pages) in it? Why not just combine them all into a video file, like *.avi or *.mpg?
Or do you just want to copy groups of 500 files into new, uniquely named folders? If so, you don't need imread at all, all you meed is movefile().
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!