Code covered by the BSD License  

Highlights from
Export image to TIF or TIFF file of selected data type

5.0

5.0 | 1 rating Rate this file 9 Downloads (last 30 days) File Size: 137.57 KB File ID: #30519

Export image to TIF or TIFF file of selected data type

by Zhang Jiang

 

24 Feb 2011

A supplement to IMWRITE to write to TIF files of data types beyond int16.

| Watch this File

File Information
Description

IMWRITE2TIF Write image to tif file with specified datatype.
 
IMWRITE2TIF(IMGDATA,HEADER,IMFILE,DATATYPE)exports IMGDATA with HEADER to TIF file named IMFILE. HEADER is usally obtained by IMFINFO from original image file, and it can also be left empty. String DATATYPE specifies data type for the export. Supported data types include logical, uint8, int8, uint16, int16, uint32, int32, uint64, int64, single and double.

IMWRITE2TIF(IMGDATA,HEADER,IMFILE,DATATYPE,TAG NAME1,TAG VALUE1,TAG NAME2,TAG VALUE2, ...) writes with specified Matlab supported TIF tag values. These new tag values override those already defined in HEADER.
 
Note 1:
to avoid errors such as '??? Error using ==> tifflib The value for MaxSampleValue must be ...', overide tag MaxSampleValue by Matlab supported values. Or simply remove the tag from HEADER.
 
Note 2:
Overwriting of the existing image files is not checked. Be cautious with the export image file name.
 
Example 1:
imgdata = imread('ngc6543a.jpg');
header = imfinfo('ngc6543a.jpg');
imwrite2tif(imgdata,header,'new_ngc6543a.tif','uint8');
 
Example 2:
imgdata = imread('mri.tif');
imwrite2tif(imgdata,[],'new_mri.tif','int32','Copyright','MRI','Compression',1);
 
More information can be found by searching for 'Exporting Image Data and Metadata to TIFF Files' in Matlab Help.

MATLAB release MATLAB 7.11 (2010b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (2)
08 Dec 2011 Hongxiao Jin

Hi, Jiang
This is just wonderful!
This is really what I am looking for. I want to save a tiff file with original double format and hundreds of images.
Just in one file!

26 Jan 2012 Adam A

I used this to export a floating-point TIFF, and it worked very well. Thanks for making it available.

Matlab should have this as a built-in function.

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
imwrite Zhang Jiang 24 Feb 2011 09:30:16
tif Zhang Jiang 24 Feb 2011 09:30:16
tiff Zhang Jiang 24 Feb 2011 09:30:17
int32 Zhang Jiang 24 Feb 2011 09:30:17
uint32 Zhang Jiang 24 Feb 2011 09:30:17
image processing Zhang Jiang 24 Feb 2011 09:30:18
16bit Zhang Jiang 26 Feb 2011 20:43:13
32bit Zhang Jiang 26 Feb 2011 20:43:13
64bit Zhang Jiang 26 Feb 2011 20:43:13

Contact us at files@mathworks.com