tiff format convert using imwrite

5 ビュー (過去 30 日間)
K.G
K.G 2017 年 12 月 28 日
回答済み: Walter Roberson 2017 年 12 月 28 日
Hi all, I have two files in tiff format. One of them is just a black and white text,and the other one is a colorful image. the black and white can be converted only to a tiff format file using imwrite code whereas the latter can also be converted to a jpg format file using imwrite(the same code) can someone explain the difference between these two tiff files and why the latter one is also convertable to a jpg format?

採用された回答

Walter Roberson
Walter Roberson 2017 年 12 月 28 日
The black and white one probably reads in as a logical array. imwrite() can write logical arrays to TIFF but not to JPEG. To write a logical array to JPEG use
ArrayGray = uint8(LogicalArray) .* uint8(255);
and then imwrite ArrayGray.
Note, though, that this would produce a grayscale JPEG image, which is fairly rare (I have only ever seen one that was not just a demonstration that creating them was possible.) Some systems might refuse to recognize grayscale JPEG images. You might need to do the conversion to Gray as I indicated and then use
ArrayRGB = ArrayGray(:,:,[1 1 1]);
and then imwrite ArrayRGB

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeConvert Image Type についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by