フィルターのクリア

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.
ZhG
ZhG 2013 年 6 月 6 日
thanks guys, I have fixed it using PNG.

サインインしてコメントする。

その他の回答 (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 Center および File ExchangeImport, Export, and Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by