Is there a way to figure out the optimal dpi for imshow when saving as a png so that all the pixels are visible?

I do something like the following:

import matplotlib.pyplot as plt
image = np.random.normal(0,1, (1000,1000))
plt.imshow(I,, interpolation='nearest', aspect='equal')
plt.savefig('~/tmp/test.png, dpi=600)

If the size of 'image' is too large or dpi is too small, the elements in the matrix get blended. I would like to set the dpi to the minimal necessary so that the elements are distinct.

Any tips appreciated.