コード例 #1
0
def viewImgMaya(arr):
    src = mlab.pipeline.scalar_field(arr)
    #mlab.pipeline.iso_surface(src, name='bone', contours=[500, 1200], opacity=1.0, color=(1, 1, 1))
    #mlab.pipeline.iso_surface(src, name='lung', contours=[-700, -600], opacity=0.3)
    # mlab.pipeline.iso_surface(src, name='fat', contours=[-100, -50], opacity=0.3, color=(1,0.5,0))
    mlab.pipeline.iso_surface(src, opacity=0.7)
    mlab.show(stop=False)
    mlab.show_pipeline(engine=None, rich_view=True)
コード例 #2
0
ファイル: vic_viz.py プロジェクト: detorto/mdvis
def do_mlab():

	gas = readfile_tex_vic(sys.argv[1])

	size = int(1920), int(1080)
	fig = mlab.figure('Viz', size=size,bgcolor=(0,0,0))
	#fig.scene.anti_aliasing_frames = 0
	#print "Drawing metal"
	#metp = mlab.points3d(metal.x,metal.y,metal.z,metal.v,scale_mode="none",scale_factor=metal.d, colormap="copper")
#	print "Drawing gas"
	print gas.x
	scatter_g = mlab.pipeline.scalar_scatter(gas.x,gas.y,gas.z,gas.t, scale_mode="none",scale_factor=gas.d)
	
	gasp = mlab.points3d(gas.x, gas.y, gas.z, gas.t, scale_mode="none",scale_factor=gas.d)
	print gas.x.min()
	print gas.x.max()
	mlab.outline()
	mlab.colorbar(title='T', orientation='vertical', nb_labels=3)

		#print "saving to ./vid/{num:02d}.png".format(num=i)
		#mlab.savefig("./vid/{num:02d}.png".format(num=i))
		#mlab.clf()
	mlab.show_pipeline()
	mlab.show()
コード例 #3
0
ファイル: tvtk_segmentation.py プロジェクト: B-Rich/mayavi
connect_ = tvtk.PolyDataConnectivityFilter(extraction_mode=4)
connect = mlab.pipeline.user_defined(smooth, filter=connect_)

# Compute normals for shading the surface
compute_normals = mlab.pipeline.poly_data_normals(connect)
compute_normals.filter.feature_angle = 80

surf = mlab.pipeline.surface(compute_normals,
                                        color=(0.9, 0.72, 0.62))

#----------------------------------------------------------------------
# Display a cut plane of the raw data
ipw = mlab.pipeline.image_plane_widget(src, colormap='bone',
                plane_orientation='z_axes',
                slice_index=55)

mlab.view(-165, 32, 350, [143, 133, 73])
mlab.roll(180)

fig.scene.disable_render = False

#----------------------------------------------------------------------
# To make the link between the Mayavi pipeline and the much more
# complex VTK pipeline, we display both:
mlab.show_pipeline(rich_view=False)
from tvtk.pipeline.browser import PipelineBrowser
browser = PipelineBrowser(fig.scene)
browser.show()

mlab.show()
コード例 #4
0
connect_ = tvtk.PolyDataConnectivityFilter(extraction_mode=4)
connect = mlab.pipeline.user_defined(smooth, filter=connect_)

# Compute normals for shading the surface
compute_normals = mlab.pipeline.poly_data_normals(connect)
compute_normals.filter.feature_angle = 80

surf = mlab.pipeline.surface(compute_normals,
                                        color=(0.9, 0.72, 0.62))

#----------------------------------------------------------------------
# Display a cut plane of the raw data
ipw = mlab.pipeline.image_plane_widget(src, colormap='bone',
                plane_orientation='z_axes',
                slice_index=55)

mlab.view(-165, 32, 350, [143, 133, 73])
mlab.roll(180)

fig.scene.disable_render = False

#----------------------------------------------------------------------
# To make the link between the Mayavi pipeline and the much more
# complex VTK pipeline, we display both:
mlab.show_pipeline(rich_view=False)
from tvtk.pipeline.browser import PipelineBrowser
browser = PipelineBrowser(fig.scene)
browser.show()

mlab.show()
コード例 #5
0
ファイル: smaug-read2.py プロジェクト: zhaomingxian/smaug
#vector = mlab.pipeline.vector_field(Bx, By)

densscalar = mlab.pipeline.scalar_field(dens)

#### Visualize the field ####################################################

fig = mlab.figure(1, size=(800, 800), bgcolor=(1, 1, 1), fgcolor=(0, 0, 0))

# Vector field first for seeing the field lines

#magnitude = mlab.pipeline.extract_vector_norm(vector)
#field_lines = mlab.pipeline.streamline(magnitude)

# Scalar field for visualisation image planes
# First the photosphere
mlab.pipeline.image_plane_widget(densscalar,
                                 plane_orientation='z_axes',
                                 slice_index=0,
                                 colormap='RdBu',
                                 transparent=False,
                                 opacity=1)

# Upper layers

#for i in range(0, max_slice):

#    mlab.pipeline.image_plane_widget(densscalar, plane_orientation='z_axes', slice_index=50, colormap='RdBu', transparent=True, opacity=0.5)

mlab.show_pipeline()
mlab.show()
コード例 #6
0
ファイル: viewCandidates.py プロジェクト: cjmielke/lung-CT
	fat: -100 to -50
	water: 0
	CSF	+15
	Kidney	+30
	Blood	+30 to +45
	Muscle	+10 to +40
	Grey matter	+37 to +45
	White matter	+20 to +30
	Liver	+40 to +60
	Soft Tissue, Contrast	+100 to +300
	Bone	+700 (cancellous bone) to +3000 (cortical bone)
	'''

    src = mlab.pipeline.scalar_field(crop)
    mlab.pipeline.iso_surface(src,
                              name='bone',
                              contours=[500, 1200],
                              opacity=1.0,
                              color=(1, 1, 1))
    mlab.pipeline.iso_surface(src,
                              name='lung',
                              contours=[-700, -600],
                              opacity=0.3)
    #mlab.pipeline.iso_surface(src, name='fat', contours=[-100, -50], opacity=0.3, color=(1,0.5,0))
    #mlab.pipeline.iso_surface(src, name='other', contours=[50, 300], opacity=0.7, color=(0,1.0,0))
    mlab.show(stop=False)
    mlab.show_pipeline(engine=None, rich_view=True)
    #response = raw_input("hit enter to continue or ctrl-c to quit")
    #time.sleep(3)
    # mlab.pipeline.iso_surface(src, contours=[s.max()-0.1*s.ptp(), ],)
コード例 #7
0
ファイル: smaug-read2.py プロジェクト: mikeg64/smaug_pmode
dens=alldat[1,:,:]

#scalar = mlab.pipeline.scalar_field(Bz)
#vector = mlab.pipeline.vector_field(Bx, By)

densscalar = mlab.pipeline.scalar_field(dens)

#### Visualize the field ####################################################

fig = mlab.figure(1, size=(800, 800), bgcolor=(1, 1, 1), fgcolor=(0, 0, 0))

# Vector field first for seeing the field lines

#magnitude = mlab.pipeline.extract_vector_norm(vector)
#field_lines = mlab.pipeline.streamline(magnitude)

# Scalar field for visualisation image planes 
# First the photosphere
mlab.pipeline.image_plane_widget(densscalar, plane_orientation='z_axes', slice_index=0, colormap='RdBu', transparent=False, opacity=1)

# Upper layers

#for i in range(0, max_slice):
    
#    mlab.pipeline.image_plane_widget(densscalar, plane_orientation='z_axes', slice_index=50, colormap='RdBu', transparent=True, opacity=0.5)



mlab.show_pipeline()
mlab.show()
コード例 #8
0
def isosurfacing(data):
    """data should be a 3d array with channel last."""
    # Heuristic for finding the threshold for the brain

    # Exctract the percentile 20 and 80 (without using
    # scipy.stats.scoreatpercentile)
    # sorted_data = np.sort(data.ravel())
    # l = len(sorted_data)
    # lower_thr = sorted_data[int(0.2 * l)]
    # upper_thr = sorted_data[int(0.8 * l)]

    # The white matter boundary: find the densest part of the upper half
    # of histogram, and take a value 10% higher, to cut _in_ the white matter
    # hist, bins = np.histogram(data[data > np.mean(data)], bins=50)
    # brain_thr_idx = np.argmax(hist)
    # brain_thr = bins[brain_thr_idx + 4]

    # del hist, bins, brain_thr_idx

    # Display the data #############################################################

    fig = mlab.figure(bgcolor=(0, 0, 0), size=(400, 500))
    # to speed things up
    fig.scene.disable_render = True

    src = mlab.pipeline.scalar_field(data)
    # Our data is not equally spaced in all directions:
    src.spacing = [1, 1, 20]
    src.update_image_data = True

    #----------------------------------------------------------------------
    # Brain extraction pipeline

    # In the following, we create a Mayavi pipeline that strongly
    # relies on VTK filters. For this, we make heavy use of the
    # mlab.pipeline.user_defined function, to include VTK filters in
    # the Mayavi pipeline.

    # Apply image-based filters to clean up noise
    # thresh_filter = tvtk.ImageThreshold()
    # thresh_filter.threshold_between(lower_thr, upper_thr)
    # thresh = mlab.pipeline.user_defined(src, filter=thresh_filter)

    median_filter = tvtk.ImageMedian3D()

    median_filter.kernel_size = [3, 3, 3]
    median = mlab.pipeline.user_defined(src, filter=median_filter)

    diffuse_filter = tvtk.ImageAnisotropicDiffusion3D(
        diffusion_factor=1.0,
        diffusion_threshold=100.0,
        number_of_iterations=5, )

    diffuse = mlab.pipeline.user_defined(median, filter=diffuse_filter)

    # Extract brain surface
    contour = mlab.pipeline.contour(diffuse, )
    contour.filter.contours = [0.5, ]

    # Apply mesh filter to clean up the mesh (decimation and smoothing)
    dec = mlab.pipeline.decimate_pro(mlab.pipeline.triangle_filter(contour))
    dec.filter.feature_angle = 60.
    dec.filter.target_reduction = 0.5

    smooth_ = tvtk.SmoothPolyDataFilter(
        number_of_iterations=10,
        relaxation_factor=0.1,
        feature_angle=60,
        feature_edge_smoothing=False,
        boundary_smoothing=False,
        convergence=0.,
    )

    smooth = mlab.pipeline.user_defined(dec, filter=smooth_)

    # Get the largest connected region
    connect_ = tvtk.PolyDataConnectivityFilter(extraction_mode=4)
    connect = mlab.pipeline.user_defined(smooth, filter=connect_)

    # Compute normals for shading the surface
    compute_normals = mlab.pipeline.poly_data_normals(connect)
    compute_normals.filter.feature_angle = 80

    surf = mlab.pipeline.surface(compute_normals,
                                 color=(1, 1, 1))

    #----------------------------------------------------------------------
    # Display a cut plane of the raw data
    ipw = mlab.pipeline.image_plane_widget(src, colormap='bone',
                                           plane_orientation='z_axes',
                                           slice_index=55)

    # mlab.view(-165, 32, 350, [143, 133, 73])
    # mlab.roll(180)

    fig.scene.disable_render = False

    #----------------------------------------------------------------------
    # To make the link between the Mayavi pipeline and the much more
    # complex VTK pipeline, we display both:
    mlab.show_pipeline(rich_view=False)
    from tvtk.pipeline.browser import PipelineBrowser
    browser = PipelineBrowser(fig.scene)
    browser.show()

    mlab.show()
コード例 #9
0
ファイル: dummy6.py プロジェクト: rosoba/rosoba
# clipActor.backface_property=backProp
##bmp1 = tvtk.JPEGReader()
##bmp1.file_name=r"C:\Program Files\Cut3D Trial\Textures\1_Materials\SeamlessPine_rotated.jpg"
# my_texture=tvtk.Texture()
# my_texture.interpolate=1
# my_texture.set_input(0,bmp1.get_output())
my_scene = e1.new_scene()
# my_scene.scene.add_actor(clipActor)

src1 = VTKDataSource(data=clipper.get_output())
e1.add_source(src1)
asurf = p3d.pipeline.surface(
    src1, opacity=1.0, name="main_cow", color=colors.white)
asurf.actor.actor.backface_property = backProp

p3d.show_pipeline()
# asurf.actor.actor.texture=my_texture

# Here we are cutting the cow. Cutting creates lines where the cut
# function intersects the model. (Clipping removes a portion of the
# model but the dimension of the data does not change.)
#
# The reason we are cutting is to generate a closed polygon at the
# boundary of the clipping process. The cutter generates line
# segments, the stripper then puts them together into polylines. We
# then pull a trick and define polygons using the closed line
# segements that the stripper created.
cutEdges = tvtk.Cutter()
cutEdges.set_input(cowNormals.get_output())
cutEdges.cut_function = plane
cutEdges.generate_cut_scalars = 1
コード例 #10
0
 def show_pipeline(self):
     """Show the Mayavi pipeline editor window."""
     mlab.show_pipeline()
コード例 #11
0
 def _mayavi_dialog_fired(self):
     mlab.show_pipeline()
コード例 #12
0
ファイル: dummy3.py プロジェクト: rosoba/rosoba
import mayavi.mlab as m
import numpy as np


def test_plot3d():
    """Generates a pretty set of lines."""
    n_mer, n_long = 6, 11
    pi = np.pi
    dphi = pi / 1000.0
    phi = np.arange(0.0, 2 * pi + 0.5 * dphi, dphi)
    mu = phi * n_mer
    x = np.cos(mu) * (1 + np.cos(n_long * mu / n_mer) * 0.5)
    y = np.sin(mu) * (1 + np.cos(n_long * mu / n_mer) * 0.5)
    z = np.sin(n_long * mu / n_mer) * 0.5

    l = m.plot3d(x, y, z, np.sin(mu), tube_radius=0.025, colormap='Spectral')

    return l

if __name__ == '__main__':

    m.text3d(1, 0, 0, 'function', orient_to_camera=False,
             orientation=(0, 0, 90), scale=0.4)

    m.show_pipeline()

    m.pipeline

    #    test_plot3d()
    m.show()
コード例 #13
0
 def showpip(self):
     mlab.show_pipeline()