After looking at various related answers, I could not figure out a straight way.
I have a 3-d numpy array of shape (390, 280, 160). I want to visualize this as an image. What could be the simplest way to do it?
Here is a minimal example of volumetric plot using mayavi.
You can find more examples of 3d data visualization here
from mayavi import mlab
import numpy as np
s = np.random.rand(20, 20, 20)
volume = mlab.pipeline.volume(mlab.pipeline.scalar_field(s), vmin=0, vmax=0.8)
mlab.draw()
mlab.savefig('output.png')

From mayavi docs
For such a visualization, tweaking the opacity transfer function is critical to achieve a good effect. Typically, it can be useful to limit the lower and upper values to the 20 and 80 percentiles of the data, in order to have a reasonable fraction of the volume transparent.
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