How to save Numpy array as image in python?

0 votes

I have a matrix in the type of a Numpy array. How would I write it to disk it as an image? Any format works (png, jpeg, bmp...). One important constraint is that PIL is not present.

Nov 16, 2018 in Python by Anirudh
• 2,070 points
1,328 views

1 answer to this question.

0 votes

If you have matplotlib, you can do:

import matplotlib.pyplot as plt
plt.imshow(matrix) #Needs to be in row,col order
plt.savefig(filename)

This will save the plot (not the images itself).

answered Nov 16, 2018 by Nymeria
• 3,500 points

Related Questions In Python

+4 votes
7 answers
+2 votes
11 answers
0 votes
1 answer
+3 votes
2 answers

how to print array integer without [] bracket in python like result = 1,2,3,4,5

Hey @abhijmr.143, you can print array integers ...READ MORE

answered Aug 4, 2018 in Python by Omkar
• 67,290 points

edited Aug 8, 2018 by Omkar 483 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 169 views
0 votes
1 answer

How to use Pandas HDF5 as a Database in Python?

HDF5 works fine for concurrent read only ...READ MORE

answered Nov 30, 2018 in Python by Nymeria
• 3,500 points

edited Dec 10, 2018 by Nymeria 86 views