How can I read the headers in complicated tiff files?

54 views (last 30 days)
Hello dear all.
I have some tiff files that contain the information that I'm looking for within their header lines.
I used imfinfo and a custom function (tiff_read_header) but still I can't get to import into matlab what I see when opening the tiff with notepad++ (please see the attached file).
I could rename the tiff files to dat and then by using importdata I can manipulate them, but still that's not a neat solution...
Any ideas?
Thank you in advance,
Melina.

Accepted Answer

Kojiro Saito
Kojiro Saito on 2 Oct 2018
How about using LibTIFF library?
t = Tiff('FILENAME.tif','r');
tagValue = t.getTag('SOME_TAG_ID');
  4 Comments
Melina Zempila
Melina Zempila on 3 Oct 2018
Hi Kojiro,
unfortunately, as I wrote above, the getTag doesn't do the work I need, simply because the information I'm looking for is not in the tags.
But your comment regarding XMP metadata led me to the following link that says how to convert tiff to json files that solves my problem!
https://stackoverflow.com/questions/9375057/xmp-toolbox-for-matlab
Best regards, Melina
P.S. Here is the content that helped me
*
I have found the answer. The best way is to download ExifTool and any Matlab JSON parser. It is possible to extract it from any file format, including .DNG, .XMP, .JPEG, .TIFF.
Step 1: Extract the info into temporary JSON file by using
system(['exiftool -struct -j ' fileName '>' tempFile]);
Step 2: Call the JSON parser on the tempFile Step 3: You have the data in Matlab struct.
*
P.S.1 The parse_json function didn't work for me but it's easy to built one of my own.
: )

Sign in to comment.

More Answers (0)

Products


Release

R2017b

Community Treasure Hunt

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

Start Hunting!