필터 지우기
필터 지우기

Optimal strategy for loading in many tiffs and resaving as imageJ tiff stacks

조회 수: 4 (최근 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
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
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

추가 답변 (1개)

Image Analyst
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().

태그

Community Treasure Hunt

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

Start Hunting!

Translated by