Time information in TIFF files

I am using "imwrite" and "WriteMode" "Append" to create a multi-tif file (a movie). I would like to include information about the time that each tif image was created in the multi-tif file. How do I add time information to the tif files?

 採用された回答

John
John 2011 年 2 月 18 日

1 投票

There is a tag called 'DateTime' that is intended for this purpose, but IMWRITE can only write a limited subset of TIFF tags, and 'DateTime' is not in that subset.
The Tiff object (introduced in R2009b) can manipulate a much broader set of tags, so it may suit your purposes better than IMWRITE. For example, to write out a multi-page TIFF consisting of the first through the 12th eigenfunctions of the L-shaped membrane, one could do something like the following:
t = Tiff('myfile.tif','w');
tagstruct.ImageWidth = 31;
tagstruct.ImageLength = 31;
tagstruct.Photometric = Tiff.Photometric.MinIsBlack;
tagstruct.BitsPerSample = 64;
tagstruct.SampleFormat = Tiff.SampleFormat.IEEEFP;
tagstruct.RowsPerStrip = 31;
tagstruct.PlanarConfiguration = Tiff.PlanarConfiguration.Chunky;
for k = 1:12
data = membrane(k);
tagstruct.DateTime = datestr(now,31);
t.setTag(tagstruct);
t.write(data);
t.writeDirectory();
end
t.close();
The 'DateTime' tag is limited to 20 characters, so if you need more temporal resolution than that, you might have to hijack another tag for your purposes, such as 'ImageDescription' or 'XMP'.

4 件のコメント

Angelina
Angelina 2012 年 9 月 4 日
this date datetime function only provides you with the modified time, not the time the file was created. is there a way to extract the creation time of the image?
Walter Roberson
Walter Roberson 2012 年 9 月 4 日
In the above context, you could record the value of "now" before the loop, and then use that recorded value each time through; that would ensure consistent times for each of the multi-page TIFF items being constructed.
But your question here is about extracting the creation time, whereas the above code is about setting a time tag. You already started a Question about extracting the times.
Angelina
Angelina 2012 年 9 月 4 日
I see, oversight on my part. Thank you for clarifying!
Xiaoli
Xiaoli 2017 年 2 月 9 日
To write in append mode change 'w' to 'a'

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeData Import and Analysis についてさらに検索

質問済み:

2011 年 1 月 26 日

コメント済み:

2017 年 2 月 9 日

Community Treasure Hunt

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

Start Hunting!

Translated by