Convert ArrayPlot Data to Matrix

I might have made a mistake here. Suppose I have spent a long time doing a calculation for an array plot as follows:

ArrayPlot[
ParallelTable[
abc[15, 1, K, n], {K, 1, 400}, {n, 1, 400}]]


Where abc is just some function that takes a while to evaluate for large K and n. Now, once the computation finished, all of the information is there, visually. But suppose I want to keep all of the data (actual numerical values) in some kind of external file. Is there any way to do this after the fact? Or is the only way to get those numbers to go back, re-compute every value again in a table, and then export that table to a .hdf file?

• why not assign it to a variable and use Export? It is even in your tags – happy fish Dec 1 '17 at 7:44

If you have the result of the ArrayPlot in a notebook, then you can recover the data.

The result will typically be of the form

Graphics[Raster[data, ...], ...]


See The Structure of Graphics and related tutorials.

Assign the plot to a variable ap and try data = ap[[1,1]]. You may need to adjust this as in principle the structure of thr graphics could be slightly different, e.g. Graphics[{Raster[data,...]}, ...], which would require ap[[1,1,1]].

Also, the elements of data may be RGB triplets instead of single numbers. You may need to figure out the original data<->colour relationship.

• Thanks, 'data = ap[[1,1]]' worked pretty well! – ereHsaWyhsipS Dec 1 '17 at 21:12