How to transform matrix into image without data loss?

3 ビュー (過去 30 日間)
Kibong Kang
Kibong Kang 2019 年 5 月 13 日
回答済み: Jyotish Kumar 2019 年 5 月 21 日
I want to save a matrix information using a image.
First, I transformed a matrix A=[0,255;255,0] into a image "1.jpg" using function "imwrite".
Second, I transformed the image "1.jpg" into "A_new" matrix using function "imread".
However, "A_new" matrix = [7,241;244,13] is not the same as "A" matrix.
How can I save and load the matrix information using the image without data loss?

回答 (2 件)

Prathamesh Degwekar
Prathamesh Degwekar 2019 年 5 月 21 日
Hi,
As far as I understand it, when imwrite converts your data array into an image, it has to use the "jpg" standard which changes the data of the array for various reasons like compression etc. Therefore when you convert the image from the matrix A into the image, that is when the data is changing into [7, 241; 244, 13].
Therefore if you want no data loss, maybe look at storing it as a bitmap image (bmp) or a raw image.
Hope this helps.
Cheers.

Jyotish Kumar
Jyotish Kumar 2019 年 5 月 21 日
JPG format compresses the file while conversion, so it changes the value. Try with another Image format like PNG which is more intact while conversion.

カテゴリ

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