Add time stamp in seconds
조회 수: 5 (최근 30일)
이전 댓글 표시
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
답변 (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
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!