image sequence Tif files to stack, switch channels to frame
10 views (last 30 days)
Show older comments
Hello all,
I have a series of tif files which are the image sequence from microscopy movie. I managed to use Tiff function to export them as a stack.
When I used ImageJ to check the properties of the stack, what I got is 74 channels (c), instead I want to get a stack has 74 frames (t).
I attach my code how to stack the image sequence here
% Images to Stacks
imagefiles = dir('*.tif');
nfiles = length(imagefiles); % Number of files found
a = 0;
b = 0;
for ii=1:nfiles
inf = imfinfo(imagefiles(ii).name);
a=max([a, inf.Height]);
b=max([b, inf.Width]);
end
tagstruct.ImageLength = a;
tagstruct.ImageWidth = b;
tagstruct.Photometric = Tiff.Photometric.MinIsBlack;
tagstruct.BitsPerSample = 16;
tagstruct.SamplesPerPixel = 1;
tagstruct.RowsPerStrip = 1;
tagstruct.PlanarConfiguration = Tiff.PlanarConfiguration.Chunky;
tagstruct.Software = 'MATLAB';
t = Tiff('Test.tif','a');
setTag(t,tagstruct)
for ii=1:nfiles
temp=uint16(zeros(a,b));
currentfilename = imagefiles(ii).name;
currentimage = imread(currentfilename);
temp(1:size(currentimage,1),1:size(currentimage,2),ii)=currentimage;
write(t,temp(:,:,ii));
writeDirectory(t);
setTag(t,tagstruct)
end
close(t)
My guess would be changing parameters in tagstruct could swich the channal and frame, but I don't know exactly how.
If anyone has an idea about how to do it, it will be so helpful.
Thank you in advance!
2 Comments
Walter Roberson
on 19 Oct 2023
ImageJ uses some private TIFF tags to signal that the TIFF is an ImageJ stack.
Answers (1)
Dheeraj
on 26 Oct 2023
Hi,
I understand that you are trying to find ways to convert channels in your tiff file to frames. The reason why ImageJ shows 74 channels (c) instead of 74 frames (t) in your stack is because by default, ImageJ imports TIF stacks as channels instead of frames.
It is possible to change how ImageJ imports TIFF stacks so that they are imported as frames instead of channels. To do this, you can use the following steps:
- Open your multi-channel TIFF stack in ImageJ.
- Go to "Image" in the menu bar.
- Select "Hyperstacks" and then choose "Stack to Hyperstack."
- In the "Stack to Hyperstack" dialog box that appears, you can specify how you want to reorganize your channels into frames. You'll need to provide the following information:
- Ensure that "Use 1 for dimension not used" is selected for the other dimensions that you are not changing (e.g., time, slices, and channels).
- Click "OK" to convert your stack into a hyperstack with channels reorganized into frames.
Hope this helps!
0 Comments
See Also
Categories
Find more on Image Processing Toolbox 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!