Finding sum of intensity in each frame of tif stack image

5 vues (au cours des 30 derniers jours)
Makunda Aryal
Makunda Aryal le 6 Nov 2022
Commenté : Makunda Aryal le 6 Nov 2022
I have 850 frames of tif image(16-bit) (41 by 41 pixels) and I want to find the sum of intensity of each frame and save that as text file for which first column would be frame number and second column sum of intensities. How can I do that?

Réponse acceptée

Kevin Holly
Kevin Holly le 6 Nov 2022
[filename, folder] = uigetfile('*.tif*');
Image_info = imfinfo(fullfile(folder,filename));
num_images = numel(Image_info);% Find how many frames are in multi-TIFF file
for ii = 1:num_images
frame = imread(fullfile(folder,filename),ii, 'Info', Image_info);% Obtains last frames in image stack
intensity(ii) = sum(sum(frame));
end
t=table;
t.Frame = (1:num_images)';
t.Intensity = intensity';
writetable(t,'filename.txt')
  3 commentaires
Kevin Holly
Kevin Holly le 6 Nov 2022
[filename, folder] = uigetfile('*.tif*');
Image_info = imfinfo(fullfile(folder,filename));
num_images = numel(Image_info);% Find how many frames are in multi-TIFF file
%Preallocate variables
intensity_Q1 = zeros(1,num_images);
intensity_Q2 = zeros(1,num_images);
intensity_Q3 = zeros(1,num_images);
intensity_Q4 = zeros(1,num_images);
for ii = 1:num_images
frame = imread(fullfile(folder,filename),ii, 'Info', Image_info);% Obtains last frames in image stack
% intensity(ii) = sum(sum(frame));
% Q1 - top left
intensity_Q1(ii) = sum(sum(frame(1:round(size(frame,1)/2),1:round(size(frame,2)/2))));
% Q2 - top right
intensity_Q2(ii) = sum(sum(frame(1:round(size(frame,1)/2),round(size(frame,2)/2)+1:end)));
% Q3 - bottom left
intensity_Q3(ii) = sum(sum(frame(round(size(frame,1)/2)+1:end,1:round(size(frame,2)/2))));
% Q4 - bottom right
intensity_Q4(ii) = sum(sum(frame(round(size(frame,1)/2)+1:end,round(size(frame,2)/2)+1:end)));
end
t=table;
t.Frame = (1:num_images)';
t.Intensity_Q1 = intensity_Q1';
t.Intensity_Q2 = intensity_Q2';
t.Intensity_Q3 = intensity_Q3';
t.Intensity_Q4 = intensity_Q4';
writetable(t,'filename.txt')
Makunda Aryal
Makunda Aryal le 6 Nov 2022
Thank you very much.

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by