Add time stamp in seconds
5 views (last 30 days)
Show older comments
I have a series of images taken at 82fps, I would like to add a time stamp in seconds at the top of each photo.
For example its 400 images of a bubble growing, so I would like to add the seconds at the top of each image.
Heres what I have so far but its not working. Thank you for the help.
clear;clc
%%%identify the window%%%
folderDir='E:\1.ACRYLIC_CHAMBER\20um_coated\vacum_test\Trial_6\1psi\test_1\dry\CUT\CUT\';
ImgSer=dir([folderDir,'*.tif']);
TimeStep=1/82; % time step between two images in min, "MODIFY THIS VALUE ACCORDING TO YOUR EXPER.."
mkdir([folderDir,'TEST'])
for i = 1:300
I=imread([folderDir,ImgSer(i).name]);
%%%% add time
ht2=text(30,30,sprintf('t= %2.2f s',TimeStep*i),'Fontname','times','fontsize',30,'Color','k');
% % % % %%%% add arrow
% % % % a=annotation('arrow',[0.2,0.2],[0.20,0.40]);%,'HeadWidth',5,'HeadLength',5);
% % % % a.Color='red';
imwrite(I,[folderDir,'TEST/',sprintf('%05d.tif',i)],'tif','compression','none');
end
0 Comments
Answers (1)
Jan
on 5 Dec 2022
The text() command inserts text in an axes. Then the text is displayed on the screen. This does not modify the image in any way. Use insertText(), which needs the Image Processing Toolbox:
% [UNTESTED CODE]
inFolder = 'E:\1.ACRYLIC_CHAMBER\20um_coated\vacum_test\Trial_6\1psi\test_1\dry\CUT\CUT\';
outFolder = fullfile(inFolder, 'TEST');
ImgSer = dir(fullfile(inFolder, '*.tif'));
TimeStep = 1/82;
mkdir(outFolder);
for i = 1:300
Img = imread(fullfile(folderDir, ImgSer(i).name));
Img = insertText(sprintf('t= %2.2f s',TimeStep*i), [10, 10], ...
'Fontname', 'Times', 'FontSize', 30, 'TextColor', 'k');
imwrite(Img, fullfile(outFolder, sprintf('%05d.tif', i)], ...
'tif', 'compression', 'none');
end
0 Comments
See Also
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!