Reputation: 923
I want to visualize how an image is represented as a matrix. I have used this answers perspective, the 2nd answer and used matplotlib.image module.
Now when I try to print the matrix, since the image consists of a large number of pixels, the matrix is not fully shown. How to see the full matrix?
I am using Anaconda compiler with Spyder as the IDE, all latest versions.
Upvotes: 1
Views: 702
Reputation: 9931
You can use matplotlib to read the image and then save it as a file
In [21]: import json
In [22]: from matplotlib import image
In [23]: f = open("out.json", "w")
In [24]: c = image.imread("02.jpg")
In [25]: f.write(json.dumps(c.tolist(), indent=4))
Out[25]: 10925444
In [26]: f.close()
Upvotes: 3