Convert imagesc back to matrix.

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.

 Respuesta aceptada

Rik
Rik el 30 de Mzo. de 2018

0 votos

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 comentarios

Liam McRoe
Liam McRoe el 30 de Mzo. de 2018
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 el 30 de Mzo. de 2018
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.
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 el 4 de Abr. de 2018
Hi, sorry for the late reply. The suggestion by Walter has worked perfectly, thanks a lot to all for the help.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Creating, Deleting, and Querying Graphics Objects en Centro de ayuda y File Exchange.

Productos

Etiquetas

Preguntada:

el 30 de Mzo. de 2018

Comentada:

el 4 de Abr. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by