First, if you just want to keep the original values or grayscale images of the raw values, the easiest way is to use PIL for this.
For example, this will create a 10x10 tif file in grayscale:
import numpy as np
import Image
data = np.random.randint(0, 255, (10,10)).astype(np.uint8)
im = Image.fromarray(data)
im.save('test.tif')
, matplotlib , , . Matplotlib ( ) dpi ( 80 100 ). , imshow , , - , .
matplotlib (, ), - :
import numpy as np
import matplotlib.pyplot as plt
dpi = 80
data = np.random.random((10, 10))
height, width = np.array(data.shape, dtype=float) / dpi
fig = plt.figure(figsize=(width, height), dpi=dpi)
ax = fig.add_axes([0, 0, 1, 1])
ax.axis('off')
ax.imshow(data, interpolation='none')
fig.savefig('test.tif', dpi=dpi)