简体   繁体   中英

Python: Big set of 2D numpy arrays… how to visualize in 3D?

I have a big set (100+) of 256x256 scalar 2D numpy arrays. Each array is basically a slice through a 3D image and each the arrays are uniformly separated.

I'm a bit of a python noob... any tips on how to create a nice 3d visualization of this data?

Do I need to compile my 100+ 2D scalar arrays into a larger 3D one?

Cheers!

You're going to need to give us a little more information, because how you visualize it depends on what you want to get out of it! Note that this question is always going to have multiple possible answers, as you're trying to display information that is inherently 3D on your 2D screen.

One way to do this is to create a movie of 2D "surface" plots, and play them back. This is basically just plotting all your slices one after another.

If you want to view all your 3D data at once, you most likely can't, as I don't know of any volumetric plotting tools for Python. Probably the closest thing is MayaVi

If you give us more information on what you want to accomplish, with as much detail as possible, we can point you to more specific examples/code resources.

Not entirely sure what you hope the visualization to look like? Sounds a bit like you want to visualize a 4D function?

You could create a 3D grid in space (see for example Numpy meshgrid in 3D ), and then use the value of the matrix/matrix number to colour the points in a scatter plot?

Might be able to be more specific if you can elaborate on what you want to see.

Edit:

Well after your comment, it still sounds like something awfully difficult to visualize, but I guess you could do something like (I've generated random data, and have a much smaller size than you will)

import matplotlib as mpl
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
import matplotlib.pyplot as plt

(X,Y,Z) = np.mgrid[-10:10:25j, -10:10:25j, -10:10:10j]

col = np.random.rand(25,25,10)

fig = plt.figure(1)
fig.clf()
ax = Axes3D(fig)

ax.scatter(X,Y,Z, c=col)

plt.draw()

plt.show()

resulting in

在此输入图像描述

Note, this may be a little less useless looking with non random data.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM