How to keep the pixel values same for writing an image

3 ビュー (過去 30 日間)
Shamim
Shamim 2017 年 12 月 17 日
回答済み: rcjr15 2018 年 2 月 19 日
In attach picture the pixel matrix D is written as an image but if i read the same image from the written one I found that all pixel values except zero are converted to 255. Why this is happening? Is there any solution to keep the pixel values same after writing it?

採用された回答

Walter Roberson
Walter Roberson 2017 年 12 月 17 日
imwrite(uint8(D), 'd.png')

その他の回答 (1 件)

rcjr15
rcjr15 2018 年 2 月 19 日
Hi Shamim, Try using this: imwrite(YourImage, 'YourFile.jpg', 'mode', 'lossless') if you want to write it as JPEG file.
Or you can use PNG or TIFF extension which are lossless compression standards.

Community Treasure Hunt

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

Start Hunting!

Translated by