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.
You can save your NumPy arrays to CSV files using the savetxt() function. This function takes a filename and array as arguments and saves the array into CSV format. You must also specify the delimiter; this is the character used to separate each variable in the file, most commonly a comma.
An answer using PIL (just in case it's useful).
given a numpy array "A":
from PIL import Image im = Image.fromarray(A) im.save("your_file.jpeg")
you can replace "jpeg" with almost any format you want. More details about the formats here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With