Convert imagesc back to matrix.
3 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
采纳的回答
Rik
2018-3-30
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 个评论
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating, Deleting, and Querying Graphics Objects 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!