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.
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.
Overwriting of the existing image files is not checked. Be cautious with the export image file name.
imgdata = imread('ngc6543a.jpg');
header = imfinfo('ngc6543a.jpg');
imgdata = imread('mri.tif');
More information can be found by searching for 'Exporting Image Data and Metadata to TIFF Files' in Matlab Help.
Zhang Jiang (2023). Export image to TIF or TIFF file of selected data type (https://www.mathworks.com/matlabcentral/fileexchange/30519-export-image-to-tif-or-tiff-file-of-selected-data-type), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform CompatibilityWindows macOS Linux
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!