- Use the "imread" function to read the original TIFF file and extract the first page's "GPSInfo" metadata using a library like the "Tiff" class.
- Apply the necessary normalization
- Use the imwrite function to create a new TIFF file for the normalized images.
- After writing each normalized image to the new TIFF file, use a custom function to add the "GPSInfo" metadata to the first page of the new TIFF file.
manipulating multipage TIFF file
6 views (last 30 days)
Show older comments
I have a geo-refenreced TIFF file with 14 pages corresponding to 14 wavelengths. I want to normalize the image at each wavelength and create a new TIFF file with the normalized images. So far no problem. My problem is that the first page in my original TIFF includes a field called "GPSInfo" that I need to pass along to the new TIFF file. Imwrite does not seem to support the inclusion of such information in a TIFF file. Any suggestions?
Thanks
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1467576/image.png)
0 Comments
Answers (1)
Dheeraj
on 6 Sep 2023
Hi,
Writing custom metadata like "GPSInfo" you can use a combination of functions from the MATLAB File Exchange and the built-in functions as "imwrite" does not support the inclusion of such information in a TIFF file.
for i = 1:14 %Iterating through all pages
% Create a new file with normalised images, let it be newNormalisedPage
% Add "GPSInfo" metadata to the first page of the new TIFF file
if i == 1
new_tiff = Tiff( newNormalisedPage , 'r+');
new_tiff.setTag('GPSInfo', gps_info);
new_tiff.close();
end
end
Also refer to https://in.mathworks.com/help/matlab/ref/imwrite.html?searchHighlight=imwrite&s_tid=srchtitle_support_results_1_imwrite for better understanding of imwrite capabilities.
See Also
Categories
Find more on Image Data in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!