def plot(image): # ax = vv.gca() # ms = vv.Mesh(ax) logging.warning([image.shape, image.spacing]) vol = image[:, :, :, 0] logging.warning([vol.min(), vol.max()]) vol = util.normalize(vol, 'ADCm') logging.warning([vol.min(), vol.max()]) vol = vv.Aarray(vol, image.spacing) cmap = None # cmap = vv.CM_VIRIDIS render_style = 'mip' # render_style = 'iso' # render_style = 'ray' # render_style = 'edgeray' # render_style = 'litray' vv.figure() vv.xlabel('x axis') vv.ylabel('y axis') vv.zlabel('z axis') a1 = vv.subplot(111) t1 = vv.volshow(vol, cm=cmap, renderStyle=render_style) t1.isoThreshold = 0.7 vv.title(render_style) # a1.camera = a2.camera = a3.camera vv.ColormapEditor(a1)
def visVol(volData): """ This example demonstrates rendering a color volume. We demonstrate two renderers capable of rendering color data: the colormip and coloriso renderer. """ import visvis as vv app = vv.use() # Load volume vol = volData # set labels vv.xlabel("x axis") vv.ylabel("y axis") vv.zlabel("z axis") # # Create figure and make subplots with different renderers # vv.figure(1); vv.clf() # RS = ['mip', 'iso', 'edgeray', 'ray', 'litray'] # a0 = None # tt = [] # for i in range(5): # a = vv.subplot(3,2,i+2) # t = vv.volshow(vol) # vv.title('Renderstyle ' + RS[i]) # t.colormap = vv.CM_HOT # t.renderStyle = RS[i] # t.isoThreshold = 200 # Only used in iso render style # tt.append(t) # if a0 is None: # a0 = a # else: # a.camera = a0.camera t = vv.volshow(vol, renderStyle="edgeray") t.colormap = vv.CM_HOT # Get axes and set camera to orthographic mode (with a field of view of 70) a = vv.gca() a.camera.fov = 45 # Create colormap editor wibject. vv.ColormapEditor(a) # Create colormap editor in first axes # cme = vv.ColormapEditor(vv.gcf(), t) # Run app # app.Create() app.Run()
def show_vox(self, vfunc): """ Displays a 3-D rendering of a voxelized property. :param vfunc: function accepting this MasonView instance and returning a 3-D np.array of some voxelized property """ app = vv.use() vv.figure(1) vv.xlabel('Eastings (units)') vv.ylabel('Northings (units)') vv.zlabel('Depth (units)') a = vv.gca() a.camera.fov = 70 a.daspect = 1, 1, -1 vox = vfunc(self) t = vv.volshow(vox, cm=vv.CM_JET, renderStyle='ray') vv.ColormapEditor(a) app.Run()
def show_layer_boundaries(self, sample): """ Displays a 3-D rendering of boundary surfaces. :param sample: index of sample for which to plot boundaries """ app = vv.use() vv.figure(1) X = np.linspace(self.xbounds[0], self.xbounds[1], self.xres) Y = np.linspace(self.ybounds[0], self.xbounds[1], self.yres) Z = np.linspace(self.zbounds[0], self.xbounds[1], self.zres) vv.xlabel('Eastings (m)') vv.ylabel('Northings (m)') vv.zlabel('Depth (m)') a = vv.gca() a.camera.fov = 70 a.daspect = 1, 1, -1 for i in range(len(self.layers)): C = plt.cm.jet(i / float(len(self.layers))) C = np.array([[[C[0], C[1], C[2]]]]) m = vv.surf(X, Y, self.fbounds[i][sample], C) vv.ColormapEditor(a) app.Run()
import visvis as vv import numpy as np app = vv.use() vv.clf() # create volume vol = vv.aVolume(size=64) # set labels vv.xlabel('x axis') vv.ylabel('y axis') vv.zlabel('z axis') # show t = vv.volshow(vol, renderStyle='mip') # try the differtent render styles, for examample # "t.renderStyle='iso'" or "t.renderStyle='ray'" # If the drawing hangs, your video drived decided to render in software mode. # This is unfortunately (as far as I know) not possible to detect. # It might help if your data is shaped a power of 2. # Get axes and set camera to orthographic mode (with a field of view of 70) a = vv.gca() a.camera.fov = 45 # Create colormap editor wibject. vv.ColormapEditor(a) # Start app app.Run()
app = vv.use() # Load volume vol = vv.volread('stent') # Create figure and make subplots with different renderers vv.figure(1) vv.clf() RS = ['mip', 'iso', 'edgeray', 'ray', 'litray'] a0 = None tt = [] for i in range(5): a = vv.subplot(3, 2, i + 2) t = vv.volshow(vol) vv.title('Renderstyle ' + RS[i]) t.colormap = vv.CM_HOT t.renderStyle = RS[i] t.isoThreshold = 200 # Only used in iso render style tt.append(t) if a0 is None: a0 = a else: a.camera = a0.camera # Create colormap editor in first axes cme = vv.ColormapEditor(vv.gcf(), *tt[3:]) # Run app app.Create() app.Run()
for deform in deforms_forward] # get backward mapping # Start vis f = vv.figure(nr) vv.clf() if nr == 1: f.position = 8.00, 30.00, 667.00, 690.00 else: f.position = 691.00, 30.00, 667.00, 690.00 a = vv.gca() a.axis.axisColor = 1, 1, 1 a.axis.visible = False a.bgcolor = 0, 0, 0 a.daspect = 1, 1, -1 vv.title('Model for LSPEAS %s - %s' % (ptcode[7:], ctcode)) vv.ColormapEditor(vv.gcf()) # Setup motion container dt = DeformableTexture3D(a, vol) dt.clim = 0, 3000 dt.isoThreshold = 300 dt.renderStyle = 'iso' # iso or mip work well dt.SetDeforms(*[list(reversed(deform)) for deform in deforms_backward]) dt.colormap = { 'g': [(0.0, 0.0), (0.33636364, 1.0)], 'b': [(0.0, 0.0), (0.49545455, 1.0)], 'a': [(0.0, 1.0), (1.0, 1.0)], 'r': [(0.0, 0.0), (0.22272727, 1.0)] } # Set limits and play!