How I can convert a tif grayscale image into other form without losing information

39 次查看(过去 30 天)
Hello,
I want to convert tif grayscale image into other forms, such as jpeg, png, or others. I searched with Google but no useful solution was found. Anyone here can help me? Appreciate.
Y.

采纳的回答

Walter Roberson
Walter Roberson 2013-6-6
Not all TIFF files can be converted to other forms without loss of information. TIFF files are allowed to contain data that is complicated in ways that cannot be reproduced in the other file formats that you mention.
If you simply need to change a grayscale image to another form, and do not need any of the complications to be transferred with it, then:
in_name = 'xyz.tif'; %the name of your input image
out_name = 'xyz_converted.jpg'; %the name of the desired output
IM = imread(in_name); %read in the image
imwrite(IM, out_name); %write it out
  2 个评论
Walter Roberson
Walter Roberson 2013-6-6
Ah... if the question is about how to invoke the "lossless" output format for the various file types, then you still use imwrite(), but you add parameters.
BMP, GIF, PGM, PPM, PCX, PNG, RAS, XWD - always lossless, no options needed
HDF4 - 'compression', 'none'
JPG, JP2 - 'mode', 'lossless'
PBM - cannot represent grayscale, do not use for this purpose
TIFF - 'Compression' with 'none' or 'packbits' or 'lzw' or 'deflate'
Note though that your original TIFF image might happen to be of higher depth than some of the formats can represent. If that is a concern, then read the imwrite() documentation.

请先登录,再进行评论。

更多回答(1 个)

Image Analyst
Image Analyst 2013-6-6
If you want to save it to disk in another format, just save your array to a file where the filename has the extension of the desired format. Be aware that some formats are lossless compression, like PNG, while others are lossy, like jpeg. If you have no preference, I'd recommend PNG.

类别

Help CenterFile Exchange 中查找有关 Import, Export, and Conversion 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by