I have a figure generated by calling imagesc on a 1000x1000 matrix. I have the figure saved, but have lost the actual data used to generate it. Is there a way for me to recover the original matrix from this figure, without having to re-run the script used to generate the matrix. TIA.

 採用された回答

Rik
Rik 2018 年 3 月 30 日

0 投票

Short answer: No.
Medium answer: Maybe, but with severely limited resolution in terms of pixels and data.
Long answer: That would depend on your needs. If the original resolution and precision is not an issue, you can crop the image part and use the colormap to convert the image back to indices (see rgb2ind). There is probably a much lower resolution in your image than the original data, and you are limited to the resolution of the colormap imagesc used and the precision of the file format it was saved to.

4 件のコメント

Liam McRoe
Liam McRoe 2018 年 3 月 30 日
Thanks for the answer, I will look into using colormap to do it.
I actually think the resolution should hopefully not be an issue. The figure is saved in the original .fig matlab figure format. Each of the entries in the original 1000x1000 matrix was of the form n/1000 for some integer n between 1 and 1000. The figure is therefore a 1000x1000 grid, with each square of the grid assigned a colour in the spectrum according to its corresponding value in the matrix. Given that there are only 1000 possible values for the entries in the matrix to take, would the data encoded within the colour of each pixel be sufficient to recover the original value in the matrix exactly?
Rik
Rik 2018 年 3 月 30 日
If you have a .fig file, your actual data might even still be there. If you attach the file, I can see how you can extract as much as there is.
Walter Roberson
Walter Roberson 2018 年 3 月 30 日
Sure, with the .fig it is easy.
imh = findobj(groot, 'type', 'image');
X = imh.XData;
Y = imh.YData;
ColorData = imh.CData;
The X and Y returned are probably going to be two-element scalars that give the locations of the centers of the lower-left and upper-right pixels.
The ColorData might perhaps be in RGB, but probably instead will be a 2D array of original unscaled data values -- the data you had asked to plot.
Liam McRoe
Liam McRoe 2018 年 4 月 4 日
Hi, sorry for the late reply. The suggestion by Walter has worked perfectly, thanks a lot to all for the help.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeConvert Image Type についてさらに検索

製品

質問済み:

2018 年 3 月 30 日

コメント済み:

2018 年 4 月 4 日

Community Treasure Hunt

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

Start Hunting!

Translated by