本文整理汇总了Python中vtk.vtkLookupTable函数的典型用法代码示例。如果您正苦于以下问题:Python vtkLookupTable函数的具体用法?Python vtkLookupTable怎么用?Python vtkLookupTable使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了vtkLookupTable函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self):
self.interactor = None
self.image_original = None
self.image_threshold = None
self.render = None
self.lut = vtk.vtkLookupTable()
self.lut_original = vtk.vtkLookupTable()
self.image_color = vtk.vtkImageMapToColors()
self.blend = blend = vtk.vtkImageBlend()
self.map = map = vtk.vtkImageMapper()
self.actor = actor = vtk.vtkImageActor()
self.actor2 = actor2 = vtk.vtkImageActor()
self.actor3 = actor3 = vtk.vtkImageActor()
self.image_color_o = vtk.vtkImageMapToColors()
self.operation_type = 0
self.w = None
self.slice = 0
self.clicked = 0
self.orientation = AXIAL
self.w = (200, 1200)
示例2: get_lookup_table
def get_lookup_table(self, display_mode):
"""
Sets up and returns the lookup table depending upon the display mode
"""
lut = vtkLookupTable()
ref_lut = vtkLookupTable()
num_colours = 256
lut.SetNumberOfColors(num_colours)
ref_lut.SetNumberOfColors(num_colours)
if (display_mode == 'load'):
lut.SetTableRange(0.0, 1.75)
ref_lut.SetTableRange(0.0, 1.75)
else:
lut.SetTableRange(0.0, 1.0)
ref_lut.SetTableRange(0.0, 1.0)
lut.Build()
ref_lut.Build()
# invert the colours: we want red to be at the high end
for j in range(num_colours):
lut.SetTableValue(j, ref_lut.GetTableValue(num_colours-1-j))
return lut
示例3: initArea
def initArea(self):
'''
Sets up the VTK simulation area
:return:None
'''
self.actors_dict = {}
self.actorCollection=vtk.vtkActorCollection()
self.borderActor = vtk.vtkActor()
self.borderActorHex = vtk.vtkActor()
self.clusterBorderActor = vtk.vtkActor()
self.clusterBorderActorHex = vtk.vtkActor()
self.cellGlyphsActor = vtk.vtkActor()
self.FPPLinksActor = vtk.vtkActor() # used for both white and colored links
self.outlineActor = vtk.vtkActor()
# self.axesActor = vtk.vtkCubeAxesActor2D()
self.axesActor = vtk.vtkCubeAxesActor()
self.outlineDim=[0,0,0]
self.cellsActor = vtk.vtkActor()
self.cellsActor.GetProperty().SetInterpolationToFlat() # ensures that pixels are drawn exactly not with interpolations/antialiasing
self.hexCellsActor = vtk.vtkActor()
self.hexCellsActor.GetProperty().SetInterpolationToFlat() # ensures that pixels are drawn exactly not with interpolations/antialiasing
self.conActor = vtk.vtkActor()
self.conActor.GetProperty().SetInterpolationToFlat()
self.hexConActor = vtk.vtkActor()
self.hexConActor.GetProperty().SetInterpolationToFlat()
self.contourActor = vtk.vtkActor()
self.glyphsActor=vtk.vtkActor()
#self.linksActor=vtk.vtkActor()
# # Concentration lookup table
self.clut = vtk.vtkLookupTable()
self.clut.SetHueRange(0.67, 0.0)
self.clut.SetSaturationRange(1.0,1.0)
self.clut.SetValueRange(1.0,1.0)
self.clut.SetAlphaRange(1.0,1.0)
self.clut.SetNumberOfColors(1024)
self.clut.Build()
# Contour lookup table
# Do I need lookup table? May be just one color?
self.ctlut = vtk.vtkLookupTable()
self.ctlut.SetHueRange(0.6, 0.6)
self.ctlut.SetSaturationRange(0,1.0)
self.ctlut.SetValueRange(1.0,1.0)
self.ctlut.SetAlphaRange(1.0,1.0)
self.ctlut.SetNumberOfColors(1024)
self.ctlut.Build()
示例4: __init__
def __init__(self, module_manager):
ModuleBase.__init__(self, module_manager)
self._volume_input = None
self._opacity_tf = vtk.vtkPiecewiseFunction()
self._colour_tf = vtk.vtkColorTransferFunction()
self._lut = vtk.vtkLookupTable()
# list of tuples, where each tuple (scalar_value, (r,g,b,a))
self._config.transfer_function = [
(0, (0,0,0), 0),
(255, (255,255,255), 1)
]
self._view_frame = None
self._create_view_frame()
self._bind_events()
self.view()
# all modules should toggle this once they have shown their
# stuff.
self.view_initialised = True
self.config_to_logic()
self.logic_to_config()
self.config_to_view()
示例5: _makeLut
def _makeLut(self):
"""
Creates vtkLookupTable for mapping the volumes
"""
random.seed(0)
lut = vtk.vtkLookupTable()
cm = self._gidToColorMap # Just simple alias
# Number of colors in LUT is equal to the largest GID +1
lut.SetNumberOfColors(max(cm.keys())+1)
# Then, allocate the table with the colors. Iterate over all color
# slots and assign proper color
for i in range(lut.GetNumberOfColors()):
# If given index is defined in indexer:
# assign its color to the lookup table
# otherwise set it to black
if i in cm:
if cm[i][0] == cm[i][1] == cm[i][2] == 119:
c = map(lambda x: float(random.randint(0, 255))/255., [0,0,0])
lut.SetTableValue(i, c[0], c[1], c[2], 1)
else:
c = cm[i]
c = map(lambda x: float(x)/255., c)
lut.SetTableValue(i, c[0], c[1], c[2], 1)
else:
lut.SetTableValue(i, 0., 0., 0., 0.)
# Build the LUT and return it
lut.SetRange(0, max(cm.keys()))
lut.Build()
return lut
示例6: initArea
def initArea(self):
# Zoom items
self.zitems = []
self.cellTypeActors={}
self.outlineActor = vtk.vtkActor()
self.outlineDim=[0,0,0]
self.invisibleCellTypes={}
self.typesInvisibleStr=""
self.set3DInvisibleTypes()
axesActor = vtk.vtkActor()
axisTextActor = vtk.vtkFollower()
self.clut = vtk.vtkLookupTable()
self.clut.SetHueRange(0.67, 0.0)
self.clut.SetSaturationRange(1.0,1.0)
self.clut.SetValueRange(1.0,1.0)
self.clut.SetAlphaRange(1.0,1.0)
self.clut.SetNumberOfColors(1024)
self.clut.Build()
## Set up the mapper and actor (3D) for concentration field.
# self.conMapper = vtk.vtkPolyDataMapper()
self.conActor = vtk.vtkActor()
self.glyphsActor=vtk.vtkActor()
# self.glyphsMapper=vtk.vtkPolyDataMapper()
self.cellGlyphsActor = vtk.vtkActor()
self.FPPLinksActor = vtk.vtkActor()
# Weird attributes
self.typeActors = {} # vtkActor
示例7: __MakeLUT
def __MakeLUT(self):
'''
Make a lookup table using vtkColorSeries.
:return: An indexed lookup table.
'''
# Make the lookup table.
pal = "../util/color_circle_Ajj.pal"
tableSize = 255
colorFunc = vtk.vtkColorTransferFunction()
scalars = self.histo()[1]
with open(pal) as f:
lines = f.readlines()
# lines.reverse()
for i, line in enumerate(lines):
l = line.strip()
r, g, b = self.__hex2rgb(l[1:])
# print scalars[i], r, g, b
colorFunc.AddRGBPoint(scalars[i], r, g, b)
lut = vtk.vtkLookupTable()
lut.SetNumberOfTableValues(tableSize)
lut.Build()
for i in range(0, tableSize):
rgb = list(colorFunc.GetColor(float(i)/tableSize))+[1]
lut.SetTableValue(i, rgb)
return lut
示例8: write
def write(self, file_name):
writer = vtk.vtkPLYWriter()
writer.SetFileName(file_name)
writer.SetInputData(self.vtk_poly_data)
if self.is_color_mode_height:
# set lookup tbale for depth values to colors
lut = vtk.vtkLookupTable()
lut.SetTableRange(self.height_min, self.height_max)
lut.Build()
# in order to be convertable to pcd, use lut to generate colors.
# THIS IS A DIRTY HACK BUT NEEDED SINCE PCL IS STUPID
# writer.SetLookupTable(lut) only works for meshlab
cur_color_data = vtk.vtkUnsignedCharArray()
cur_color_data.SetNumberOfComponents(3)
for id in self.color_ids:
val = self.color_data.GetValue(id)
col = [0., 0., 0.]
lut.GetColor(val, col)
col = [int(c * 255) for c in col]
cur_color_data.InsertNextTuple3(col[0], col[1], col[2])
self.color_data = cur_color_data
self.color_data.SetName("Colors")
self.vtk_poly_data.GetPointData().SetActiveScalars('Colors')
self.vtk_poly_data.GetPointData().SetScalars(self.color_data)
writer.SetArrayName("Colors")
writer.Write()
示例9: __init__
def __init__(self, filename, max_num_of_vertices=-1, edge_color_filename=None):
super(VTKVisualizer, self).__init__()
self.vertex_id_idx_map = {}
self.next_vertex_id = 0
self.edge_counter = 0
self.lookup_table = vtk.vtkLookupTable()
self.lookup_table.SetNumberOfColors(int(1e8))
self.edge_color_tuples = {}
self.edge_color_filename = edge_color_filename
self.label_vertex_id_map = {}
self.starting_vertex = None
self.starting_vertex_index = -1
self.filename = filename
self.max_num_of_vertices = max_num_of_vertices
self.g = vtk.vtkMutableDirectedGraph()
self.vertex_ids = vtk.vtkIntArray()
self.vertex_ids.SetNumberOfComponents(1)
self.vertex_ids.SetName(VERTEX_ID)
self.labels = vtk.vtkStringArray()
self.labels.SetNumberOfComponents(1)
self.labels.SetName(LABELS)
self.glyph_scales = vtk.vtkFloatArray()
self.glyph_scales.SetNumberOfComponents(1)
self.glyph_scales.SetName(SCALES)
self.edge_weights = vtk.vtkDoubleArray()
self.edge_weights.SetNumberOfComponents(1)
self.edge_weights.SetName(WEIGHTS)
self.edge_colors = vtk.vtkIntArray()
self.edge_colors.SetNumberOfComponents(1)
self.edge_colors.SetName(EDGE_COLORS)
示例10: setParams
def setParams(self):
# # You can use either Build() method (256 color by default) or
# # SetNumberOfTableValues() to allocate much more colors!
# self.celltypeLUT = vtk.vtkLookupTable()
# # You need to explicitly call Build() when constructing the LUT by hand
# self.celltypeLUT.Build()
#
# self.populate_cell_type_lookup_table()
# self.populateLookupTable()
# self.dim = [100, 100, 1] # Default values
# for FPP links (and offset also for cell glyphs)
self.eps = 1.e-4 # not sure how small this should be (checking to see if cell volume -> 0)
self.stubSize = 3.0 # dangling line stub size for lines that wraparound periodic BCs
# self.offset = 1.0 # account for fact that COM of cell is offset from visualized lattice
# self.offset = 0.0 # account for fact that COM of cell is offset from visualized lattice
# scaling factors to map square lattice to hex lattice (rf. CC3D Manual)
self.xScaleHex = 1.0
self.yScaleHex = 0.866
self.zScaleHex = 0.816
self.lutBlueRed = vtk.vtkLookupTable()
self.lutBlueRed.SetHueRange(0.667, 0.0)
self.lutBlueRed.Build()
示例11: MakeLUT
def MakeLUT(tableSize):
'''
Make a lookup table from a set of named colors.
:param: tableSize - The table size
:return: The lookup table.
'''
nc = vtk.vtkNamedColors()
lut = vtk.vtkLookupTable()
lut.SetNumberOfTableValues(tableSize)
lut.Build()
# Fill in a few known colors, the rest will be generated if needed
lut.SetTableValue(0,nc.GetColor4d("Black"))
lut.SetTableValue(1,nc.GetColor4d("Banana"))
lut.SetTableValue(2,nc.GetColor4d("Tomato"))
lut.SetTableValue(3,nc.GetColor4d("Wheat"))
lut.SetTableValue(4,nc.GetColor4d("Lavender"))
lut.SetTableValue(5,nc.GetColor4d("Flesh"))
lut.SetTableValue(6,nc.GetColor4d("Raspberry"))
lut.SetTableValue(7,nc.GetColor4d("Salmon"))
lut.SetTableValue(8,nc.GetColor4d("Mint"))
lut.SetTableValue(9,nc.GetColor4d("Peacock"))
return lut
示例12: jet
def jet(self, m=256):
# blue, cyan, green, yellow, red, black
lut = vtk.vtkLookupTable()
lut.SetNumberOfColors(m)
lut.SetHueRange(0.667,0.0)
lut.Build()
return lut
示例13: do_colour_mask
def do_colour_mask(self, imagedata):
scalar_range = int(imagedata.GetScalarRange()[1])
r, g, b = self.current_mask.colour
# map scalar values into colors
lut_mask = vtk.vtkLookupTable()
lut_mask.SetNumberOfColors(256)
lut_mask.SetHueRange(const.THRESHOLD_HUE_RANGE)
lut_mask.SetSaturationRange(1, 1)
lut_mask.SetValueRange(0, 255)
lut_mask.SetRange(0, 255)
lut_mask.SetNumberOfTableValues(256)
lut_mask.SetTableValue(0, 0, 0, 0, 0.0)
lut_mask.SetTableValue(1, 0, 0, 0, 0.0)
lut_mask.SetTableValue(254, r, g, b, 1.0)
lut_mask.SetTableValue(255, r, g, b, 1.0)
lut_mask.SetRampToLinear()
lut_mask.Build()
# self.lut_mask = lut_mask
# map the input image through a lookup table
img_colours_mask = vtk.vtkImageMapToColors()
img_colours_mask.SetLookupTable(lut_mask)
img_colours_mask.SetOutputFormatToRGBA()
img_colours_mask.SetInput(imagedata)
img_colours_mask.Update()
# self.img_colours_mask = img_colours_mask
return img_colours_mask.GetOutput()
示例14: addArrayFromIdList
def addArrayFromIdList(self, connectedIdList, inputModelNode, arrayName):
if not inputModelNode:
return
inputModelNodePolydata = inputModelNode.GetPolyData()
pointData = inputModelNodePolydata.GetPointData()
numberofIds = connectedIdList.GetNumberOfIds()
hasArrayInt = pointData.HasArray(arrayName)
if hasArrayInt == 1: # ROI Array found
pointData.RemoveArray(arrayName)
arrayToAdd = vtk.vtkDoubleArray()
arrayToAdd.SetName(arrayName)
for i in range(0, inputModelNodePolydata.GetNumberOfPoints()):
arrayToAdd.InsertNextValue(0.0)
for i in range(0, numberofIds):
arrayToAdd.SetValue(connectedIdList.GetId(i), 1.0)
lut = vtk.vtkLookupTable()
tableSize = 2
lut.SetNumberOfTableValues(tableSize)
lut.Build()
ID = inputModelNode.GetDisplayNodeID()
slicer.app.mrmlScene().GetNodeByID(ID)
displayNode = slicer.app.mrmlScene().GetNodeByID(ID)
rgb = displayNode.GetColor()
lut.SetTableValue(0, rgb[0], rgb[1], rgb[2], 1)
lut.SetTableValue(1, 1.0, 0.0, 0.0, 1)
arrayToAdd.SetLookupTable(lut)
pointData.AddArray(arrayToAdd)
inputModelNodePolydata.Modified()
return True
示例15: setParams
def setParams(self):
# You can use either Build() method (256 color by default) or
# SetNumberOfTableValues() to allocate much more colors!
self.lut = vtk.vtkLookupTable()
# You need to explicitly call Build() when constructing the LUT by hand
self.lut.Build()
self.populateLookupTable()