Add time stamp in seconds
古いコメントを表示
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
回答 (1 件)
Jan
2022 年 12 月 5 日
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
カテゴリ
ヘルプ センター および File Exchange で Startup and Shutdown についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!