Convert matrix to image and image to matrix

6 views (last 30 days)
Hi, I have a matrix with values between 1 - 10, and I would like to transform that in a kind of image.
and after that, I would like transform the image into the same previous matrix.
Could someone help me?

Answers (1)

Walter Roberson
Walter Roberson on 9 Nov 2016
AsImage = uint8(YourMatrix .* (255/10));
BackAsMatrix = double(AsImage) .* (10/255);
  2 Comments
Fernando Silveira
Fernando Silveira on 9 Nov 2016
Thanks. But what if I want to save the image(.png, .bmp, .jpg, I don't know...) and then open (or read) it?

Sign in to comment.

Categories

Find more on Convert Image Type in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!