本文整理汇总了Python中vtk.vtkImageMapper函数的典型用法代码示例。如果您正苦于以下问题:Python vtkImageMapper函数的具体用法?Python vtkImageMapper怎么用?Python vtkImageMapper使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了vtkImageMapper函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.ui = Ui_Form()
self.ui.setupUi(self)
self.reader = vtk.vtkDICOMImageReader()
#self.viewerL = vtk.vtkImageViewer2()
#self.viewerR = vtk.vtkImageViewer2()
self.renL = vtk.vtkRenderer()
self.ui.leftVtk.GetRenderWindow().AddRenderer(self.renL)
self.renR = vtk.vtkRenderer()
self.ui.rightVtk.GetRenderWindow().AddRenderer(self.renR)
self.mapperL = vtk.vtkImageMapper()
self.mapperL.SetInputConnection(self.reader.GetOutputPort())
self.mapperR = vtk.vtkImageMapper()
self.actorL = vtk.vtkActor2D()
self.actorL.SetMapper(self.mapperL)
self.actorR = vtk.vtkActor2D()
self.actorR.SetMapper(self.mapperR)
self.renL.AddActor2D(self.actorL)
self.renR.AddActor2D(self.actorR)
self.importer = vtk.vtkImageImport()
self.mapperR.SetInputConnection(self.importer.GetOutputPort())
self.loadImage(os.path.join(STARTINGPATH, FILENAME))
self.setWindowingAlg()
开发者ID:MKozuch,项目名称:MIEnhancer,代码行数:32,代码来源:ImagingEnhancer.py
示例2: __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)
开发者ID:151706061,项目名称:invesalius3,代码行数:27,代码来源:editor.py
示例3: _init_canvas
def _init_canvas(self):
w, h = self._size
self._array = np.zeros((h, w, 4), dtype=np.uint8)
self._cv_image = converters.np_rgba_to_vtk(self._array)
self.mapper = vtk.vtkImageMapper()
self.mapper.SetInputData(self._cv_image)
self.mapper.SetColorWindow(255)
self.mapper.SetColorLevel(128)
self.actor = vtk.vtkActor2D()
self.actor.SetPosition(0, 0)
self.actor.SetMapper(self.mapper)
self.actor.GetProperty().SetOpacity(0.99)
self.canvas_renderer.AddActor2D(self.actor)
self.rgb = np.zeros((h, w, 3), dtype=np.uint8)
self.alpha = np.zeros((h, w, 1), dtype=np.uint8)
self.bitmap = wx.EmptyBitmapRGBA(w, h)
try:
self.image = wx.Image(w, h, self.rgb, self.alpha)
except TypeError:
self.image = wx.ImageFromBuffer(w, h, self.rgb, self.alpha)
开发者ID:paulojamorim,项目名称:invesalius3,代码行数:26,代码来源:canvas_renderer.py
示例4: __init__
def __init__(self):
self.lookupTable = vtk.vtkLookupTable()
self.lookupTable.SetRampToLinear()
self.lookupTable.SetNumberOfTableValues(2)
self.lookupTable.SetTableRange(0, 1)
self.lookupTable.SetTableValue(0, 0, 0, 0, 0)
self.colorMapper = vtk.vtkImageMapToRGBA()
self.colorMapper.SetOutputFormatToRGBA()
self.colorMapper.SetLookupTable(self.lookupTable)
self.thresholdFilter = vtk.vtkImageThreshold()
self.thresholdFilter.SetInValue(1)
self.thresholdFilter.SetOutValue(0)
self.thresholdFilter.SetOutputScalarTypeToUnsignedChar()
# Feedback actor
self.mapper = vtk.vtkImageMapper()
self.dummyImage = vtk.vtkImageData()
self.dummyImage.AllocateScalars(vtk.VTK_UNSIGNED_INT, 1)
self.mapper.SetInputData(self.dummyImage)
self.actor = vtk.vtkActor2D()
self.actor.VisibilityOff()
self.actor.SetMapper(self.mapper)
self.mapper.SetColorWindow(255)
self.mapper.SetColorLevel(128)
# Setup pipeline
self.colorMapper.SetInputConnection(self.thresholdFilter.GetOutputPort())
self.mapper.SetInputConnection(self.colorMapper.GetOutputPort())
开发者ID:BRAINSia,项目名称:Slicer,代码行数:28,代码来源:SegmentEditorThresholdEffect.py
示例5: __init__
def __init__(self, sliceWidget):
super(ThresholdEffectTool,self).__init__(sliceWidget)
# create a logic instance to do the non-gui work
self.logic = ThresholdEffectLogic(self.sliceWidget.sliceLogic())
self.logic.undoRedo = self.undoRedo
# interaction state variables
self.min = 0
self.max = 0
# class instances
self.lut = None
self.thresh = None
self.map = None
# feedback actor
self.cursorMapper = vtk.vtkImageMapper()
self.cursorDummyImage = vtk.vtkImageData()
self.cursorDummyImage.AllocateScalars(vtk.VTK_UNSIGNED_INT, 1)
self.cursorMapper.SetInputData( self.cursorDummyImage )
self.cursorActor = vtk.vtkActor2D()
self.cursorActor.VisibilityOff()
self.cursorActor.SetMapper( self.cursorMapper )
self.cursorMapper.SetColorWindow( 255 )
self.cursorMapper.SetColorLevel( 128 )
self.actors.append( self.cursorActor )
self.renderer.AddActor2D( self.cursorActor )
开发者ID:BRAINSia,项目名称:Slicer,代码行数:30,代码来源:ThresholdEffect.py
示例6: __init__
def __init__(self,parent=None,width=400,height=400,showWidget=False,scale=False):
super(LayerReveal,self).__init__()
self.width = width
self.height = height
self.showWidget = showWidget
self.scale = scale
self.renderer = None
# utility Qt instances for use in methods
self.gray = qt.QColor()
self.gray.setRedF(0.5)
self.gray.setGreenF(0.5)
self.gray.setBlueF(0.5)
# a painter to use for various jobs
self.painter = qt.QPainter()
# make a qwidget display
if self.showWidget:
self.frame = qt.QFrame(parent)
mw = slicer.util.mainWindow()
self.frame.setGeometry(mw.x, mw.y, self.width, self.height)
self.frameLayout = qt.QVBoxLayout(self.frame)
self.label = qt.QLabel()
self.frameLayout.addWidget(self.label)
self.frame.show()
# make an image actor in the slice view
self.vtkImage = vtk.vtkImageData()
self.mrmlUtils = slicer.qMRMLUtils()
self.imageMapper = vtk.vtkImageMapper()
self.imageMapper.SetColorLevel(128)
self.imageMapper.SetColorWindow(255)
if vtk.VTK_MAJOR_VERSION <= 5:
self.imageMapper.SetInput(self.vtkImage)
else:
self.imageMapper.SetInputData(self.vtkImage)
self.actor2D = vtk.vtkActor2D()
self.actor2D.SetMapper(self.imageMapper)
开发者ID:pieper,项目名称:CompareVolumes,代码行数:40,代码来源:CompareVolumes.py
示例7: testAllMathematics
def testAllMathematics(self):
# append multiple displaced spheres into an RGB image.
# Image pipeline
renWin = vtk.vtkRenderWindow()
sphere1 = vtk.vtkImageEllipsoidSource()
sphere1.SetCenter(40, 20, 0)
sphere1.SetRadius(30, 30, 0)
sphere1.SetInValue(.75)
sphere1.SetOutValue(.3)
sphere1.SetOutputScalarTypeToFloat()
sphere1.SetWholeExtent(0, 99, 0, 74, 0, 0)
sphere1.Update()
sphere2 = vtk.vtkImageEllipsoidSource()
sphere2.SetCenter(60, 30, 0)
sphere2.SetRadius(20, 20, 20)
sphere2.SetInValue(.2)
sphere2.SetOutValue(.5)
sphere2.SetOutputScalarTypeToFloat()
sphere2.SetWholeExtent(0, 99, 0, 74, 0, 0)
sphere2.Update()
mathematics = [ "Add", "Subtract", "Multiply", "Divide", "Invert", "Sin", "Cos",
"Exp", "Log", "AbsoluteValue", "Square", "SquareRoot", "Min",
"Max", "ATAN", "ATAN2", "MultiplyByK", "ReplaceCByK", "AddConstant"]
mathematic = list()
mapper = list()
actor = list()
imager = list()
for idx, operator in enumerate(mathematics):
mathematic.append(vtk.vtkImageMathematics())
mathematic[idx].SetInput1Data(sphere1.GetOutput())
mathematic[idx].SetInput2Data(sphere2.GetOutput())
eval('mathematic[idx].SetOperationTo' + operator + '()')
mathematic[idx].SetConstantK(.3)
mathematic[idx].SetConstantC(.75)
mapper.append(vtk.vtkImageMapper())
mapper[idx].SetInputConnection(mathematic[idx].GetOutputPort())
mapper[idx].SetColorWindow(2.0)
mapper[idx].SetColorLevel(.75)
actor.append(vtk.vtkActor2D())
actor[idx].SetMapper(mapper[idx])
imager.append(vtk.vtkRenderer())
imager[idx].AddActor2D(actor[idx])
renWin.AddRenderer(imager[idx])
column = 1
row = 1
deltaX = 1.0 / 6.0
deltaY = 1.0 / 4.0
for idx, operator in enumerate(mathematics):
imager[idx].SetViewport((column - 1) * deltaX, (row - 1) * deltaY, column * deltaX, row * deltaY)
column += 1
if column > 6:
column = 1
row += 1
# Make the last operator finish the row
vp = imager[len(mathematics) - 1].GetViewport()
imager[len(mathematics) - 1].SetViewport(vp[0], vp[1], 1, 1)
renWin.SetSize(600, 300)
# render and interact with data
iRen = vtk.vtkRenderWindowInteractor()
iRen.SetRenderWindow(renWin);
renWin.Render()
img_file = "TestAllMathematics.png"
vtk.test.Testing.compareImage(iRen.GetRenderWindow(), vtk.test.Testing.getAbsImagePath(img_file), threshold=25)
vtk.test.Testing.interact()
开发者ID:timkrentz,项目名称:SunTracker,代码行数:80,代码来源:TestAllMathematics.py
示例8: print
print("GetAlphaBitPlanes: " + str(renWin.GetAlphaBitPlanes()))
# create window to image filter, grabbing RGB and alpha
w2i = vtk.vtkWindowToImageFilter()
w2i.SetInput(renWin)
w2i.SetInputBufferTypeToRGBA()
# grab window
w2i.Update()
# copy the output
outputData = w2i.GetOutput().NewInstance()
outputData.DeepCopy(w2i.GetOutput())
# set up mappers and actors to display the image
im = vtk.vtkImageMapper()
im.SetColorWindow(255)
im.SetColorLevel(127.5)
im.SetInputData(outputData)
ia2 = vtk.vtkActor2D()
ia2.SetMapper(im)
# now, change the image (background is now green)
sphactor.SetScale(2, 2, 2)
ren1.SetBackground(0, 1, 0)
# add the image of the sphere (keeping the original sphere too)
ren1.AddActor(ia2)
ren1.SetViewport(0, 0, 1, 1)
开发者ID:ColorVertexSampleOrganization,项目名称:VTK,代码行数:30,代码来源:TestWindowToImageTransparency.py
示例9: testAllShrinks
def testAllShrinks(self):
prefix = VTK_DATA_ROOT + "/Data/headsq/quarter"
renWin = vtk.vtkRenderWindow()
# Image pipeline
reader = vtk.vtkImageReader()
reader.SetDataExtent(0, 63, 0, 63, 1, 93)
reader.SetFilePrefix(prefix)
reader.SetDataByteOrderToLittleEndian()
reader.SetDataMask(0x7fff)
factor = 4
magFactor = 8
ops = ["Minimum", "Maximum", "Mean", "Median", "NoOp"]
shrink = dict()
mag = dict()
mapper = dict()
actor = dict()
imager = dict()
for operator in ops:
shrink.update({operator:vtk.vtkImageShrink3D()})
shrink[operator].SetMean(0)
if operator != "NoOp":
eval('shrink[operator].' + operator + 'On()')
shrink[operator].SetShrinkFactors(factor, factor, factor)
shrink[operator].SetInputConnection(reader.GetOutputPort())
mag.update({operator:vtk.vtkImageMagnify()})
mag[operator].SetMagnificationFactors(magFactor, magFactor, magFactor)
mag[operator].InterpolateOff()
mag[operator].SetInputConnection(shrink[operator].GetOutputPort())
mapper.update({operator:vtk.vtkImageMapper()})
mapper[operator].SetInputConnection(mag[operator].GetOutputPort())
mapper[operator].SetColorWindow(2000)
mapper[operator].SetColorLevel(1000)
mapper[operator].SetZSlice(45)
actor.update({operator:vtk.vtkActor2D()})
actor[operator].SetMapper(mapper[operator])
imager.update({operator:vtk.vtkRenderer()})
imager[operator].AddActor2D(actor[operator])
renWin.AddRenderer(imager[operator])
shrink["Minimum"].Update
shrink["Maximum"].Update
shrink["Mean"].Update
shrink["Median"].Update
imager["Minimum"].SetViewport(0, 0, .5, .33)
imager["Maximum"].SetViewport(0, .33, .5, .667)
imager["Mean"].SetViewport(.5, 0, 1, .33)
imager["Median"].SetViewport(.5, .33, 1, .667)
imager["NoOp"].SetViewport(0, .667, 1, 1)
renWin.SetSize(256, 384)
# render and interact with data
iRen = vtk.vtkRenderWindowInteractor()
iRen.SetRenderWindow(renWin);
renWin.Render()
img_file = "TestAllShrinks.png"
vtk.test.Testing.compareImage(iRen.GetRenderWindow(), vtk.test.Testing.getAbsImagePath(img_file), threshold=25)
vtk.test.Testing.interact()
开发者ID:151706061,项目名称:VTK,代码行数:70,代码来源:TestAllShrinks.py
示例10:
source = mabdi.SourceEnvironmentTable()
source.Update()
fdi = mabdi.FilterDepthImage(offscreen=False)
fdi.set_polydata(source)
# show output of the filter
ren = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
iren = vtk.vtkRenderWindowInteractor()
renWin.AddRenderer(ren)
iren.SetRenderWindow(renWin)
renWin.SetSize(640, 480)
imageMapper = vtk.vtkImageMapper()
imageMapper.SetInputConnection(fdi.GetOutputPort())
imageMapper.SetColorWindow(1.0)
imageMapper.SetColorLevel(0.5)
imageActor = vtk.vtkActor2D()
imageActor.SetMapper(imageMapper)
ren.AddActor(imageActor)
iren.Initialize()
iren.Render()
rang = np.arange(-40, 41, dtype=float)
position = np.vstack((rang/20,
np.ones(len(rang)),
np.ones(len(rang))*2)).T
lookat = np.vstack((rang/40,
开发者ID:lucasplus,项目名称:MABDI,代码行数:31,代码来源:TestFilterDepthImage.py
示例11:
stencil1.SetInputConnection(reader.GetOutputPort())
stencil1.SetBackgroundInputData(shiftScale.GetOutput())
stencil1.SetStencilConnection(roiStencil1.GetOutputPort())
stencil2 = vtk.vtkImageStencil()
stencil2.SetInputConnection(reader.GetOutputPort())
stencil2.SetBackgroundInputData(shiftScale.GetOutput())
stencil2.SetStencilConnection(roiStencil2.GetOutputPort())
stencil3 = vtk.vtkImageStencil()
stencil3.SetInputConnection(reader.GetOutputPort())
stencil3.SetBackgroundInputData(shiftScale.GetOutput())
stencil3.SetStencilConnection(roiStencil3.GetOutputPort())
stencil4 = vtk.vtkImageStencil()
stencil4.SetInputConnection(reader.GetOutputPort())
stencil4.SetBackgroundInputData(shiftScale.GetOutput())
stencil4.SetStencilConnection(roiStencil4.GetOutputPort())
mapper1 = vtk.vtkImageMapper()
mapper1.SetInputConnection(stencil1.GetOutputPort())
mapper1.SetColorWindow(2000)
mapper1.SetColorLevel(1000)
mapper1.SetZSlice(0)
mapper2 = vtk.vtkImageMapper()
mapper2.SetInputConnection(stencil2.GetOutputPort())
mapper2.SetColorWindow(2000)
mapper2.SetColorLevel(1000)
mapper2.SetZSlice(0)
mapper3 = vtk.vtkImageMapper()
mapper3.SetInputConnection(stencil3.GetOutputPort())
mapper3.SetColorWindow(2000)
mapper3.SetColorLevel(1000)
mapper3.SetZSlice(0)
mapper4 = vtk.vtkImageMapper()
开发者ID:timkrentz,项目名称:SunTracker,代码行数:31,代码来源:TestLassoStencil.py
示例12: vtkGetDataRoot
#!/usr/bin/env python
import vtk
from vtk.util.misc import vtkGetDataRoot
VTK_DATA_ROOT = vtkGetDataRoot()
#
# display text over an image
#
ellipse = vtk.vtkImageEllipsoidSource()
mapImage = vtk.vtkImageMapper()
mapImage.SetInputConnection(ellipse.GetOutputPort())
mapImage.SetColorWindow(255)
mapImage.SetColorLevel(127.5)
img = vtk.vtkActor2D()
img.SetMapper(mapImage)
mapText = vtk.vtkTextMapper()
mapText.SetInput("Text Overlay")
mapText.GetTextProperty().SetFontSize(15)
mapText.GetTextProperty().SetColor(0,1,1)
mapText.GetTextProperty().BoldOn()
mapText.GetTextProperty().ShadowOn()
txt = vtk.vtkActor2D()
txt.SetMapper(mapText)
txt.SetPosition(138,128)
ren1 = vtk.vtkRenderer()
ren1.AddActor2D(img)
ren1.AddActor2D(txt)
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren1)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
开发者ID:ElsevierSoftwareX,项目名称:SOFTX-D-15-00004,代码行数:31,代码来源:OverlayTextOnImage.py
示例13: _CreateLabel
#.........这里部分代码省略.........
scalars = vtk.vtkUnsignedCharArray()
scalars.InsertTuple1(0, 0)
scalars.InsertTuple1(1, 2)
scalars.InsertTuple1(2, 2)
scalars.InsertTuple1(3, 3)
scalars.InsertTuple1(4, 3)
data = vtk.vtkPolyData()
data.SetPoints(self._Points)
data.SetPolys(cells)
data.GetCellData().SetScalars(scalars)
mapper = vtk.vtkPolyDataMapper2D()
mapper.SetInput(data)
mapper.SetLookupTable(self._LookupTable)
mapper.SetColorModeToMapScalars()
mapper.SetScalarRange(0, 3)
actor = vtk.vtkActor2D()
actor.SetMapper(mapper)
actor.SetPosition(x - x0, y - y0)
self._Scalars = scalars
self._Actors.append(actor)
if self._Renderer:
self._Renderer.AddActor2D(actor)
# if there is a bitmap
if image:
image.UpdateInformation()
extent = image.GetExtent() # VTK 6
spacing = image.GetSpacing()
origin = image.GetOrigin()
newextent = (0, width - 1 - borderwidth * 2,
0, height - 1 - borderwidth * 2,
extent[4], extent[5])
newspacing = (spacing[0] * float(extent[1] - extent[0]) /
float(newextent[1] - newextent[0]),
spacing[1] * float(extent[3] - extent[2]) /
float(newextent[3] - newextent[2]),
spacing[2])
neworigin = (origin[0] + extent[0] * spacing[0] -
newextent[0] * newspacing[0],
origin[1] + extent[2] * spacing[1] -
newextent[2] * newspacing[1],
origin[2])
reslice = vtk.vtkImageReslice()
reslice.SetInput(image)
reslice.SetInterpolationModeToCubic()
reslice.SetOutputExtent(newextent)
reslice.SetOutputSpacing(newspacing)
reslice.SetOutputOrigin(neworigin)
self._BitmapReslice = reslice
mapper = vtk.vtkImageMapper()
mapper.SetInput(reslice.GetOutput())
mapper.SetColorWindow(255.0)
mapper.SetColorLevel(127.5)
actor = vtk.vtkActor2D()
actor.SetMapper(mapper)
actor.SetPosition(x - x0, y - y0)
self._Actors.append(actor)
if self._Renderer:
self._Renderer.AddActor2D(actor)
mapper = vtk.vtkTextMapper()
mapper.SetInput(self._Config['text'])
try:
property = mapper.GetTextProperty()
except AttributeError:
property = mapper
property.SetFontSize(self._Config['fontsize'])
if self._Config['font'] in ('courier', 'Courier'):
property.SetFontFamilyToCourier()
elif self._Config['font'] in ('arial', 'Arial'):
property.SetFontFamilyToArial()
elif self._Config['font'] in ('times', 'Times'):
property.SetFontFamilyToTimes()
property.SetJustificationToCentered()
property.SetVerticalJustificationToCentered()
property.BoldOn()
self._TextMapper = mapper
actor = vtk.vtkActor2D()
actor.GetProperty().SetColor(*self._Config['foreground'])
actor.SetMapper(mapper)
if "FreeType" in mapper.GetClassName():
actor.SetPosition(x + old_div(width, 2) - x0,
y + old_div(height, 2) - y0)
else: # not a FreeType font, needs position correction
actor.SetPosition(x + old_div(width, 2) - x0 + 1,
y + old_div(height, 2) - y0 + 1)
self._Actors.append(actor)
if self._Renderer:
self._Renderer.AddActor2D(actor)
开发者ID:parallaxinnovations,项目名称:vtkAtamai,代码行数:101,代码来源:Label.py
示例14: __init__
def __init__(self, in_source):
self.mapper = vtk.vtkImageMapper()
self.mapper.SetInputConnection(in_source.GetOutputPort())
self.actor = vtk.vtkActor2D()
self.actor.SetMapper(self.mapper)
开发者ID:lucasplus,项目名称:MABDI,代码行数:6,代码来源:Utilities.py
示例15: testAllLogic
def testAllLogic(self):
# append multiple displaced spheres into an RGB image.
# Image pipeline
renWin = vtk.vtkRenderWindow()
logics = ["And", "Or", "Xor", "Nand", "Nor", "Not"]
types = ["Float", "Double", "UnsignedInt", "UnsignedLong", "UnsignedShort", "UnsignedChar"]
sphere1 = list()
sphere2 = list()
logic = list()
mapper = list()
actor = list()
imager = list()
for idx, operator in enumerate(logics):
ScalarType = types[idx]
sphere1.append(vtk.vtkImageEllipsoidSource())
sphere1[idx].SetCenter(95, 100, 0)
sphere1[idx].SetRadius(70, 70, 70)
eval('sphere1[idx].SetOutputScalarTypeTo' + ScalarType + '()')
sphere1[idx].Update()
sphere2.append(vtk.vtkImageEllipsoidSource())
sphere2[idx].SetCenter(161, 100, 0)
sphere2[idx].SetRadius(70, 70, 70)
eval('sphere2[idx].SetOutputScalarTypeTo' + ScalarType + '()')
sphere2[idx].Update()
logic.append(vtk.vtkImageLogic())
logic[idx].SetInput1Data(sphere1[idx].GetOutput())
if operator != "Not":
logic[idx].SetInput2Data(sphere2[idx].GetOutput())
logic[idx].SetOutputTrueValue(150)
eval('logic[idx].SetOperationTo' + operator + '()')
mapper.append(vtk.vtkImageMapper())
mapper[idx].SetInputConnection(logic[idx].GetOutputPort())
mapper[idx].SetColorWindow(255)
mapper[idx].SetColorLevel(127.5)
actor.append(vtk.vtkActor2D())
actor[idx].SetMapper(mapper[idx])
imager.append(vtk.vtkRenderer())
imager[idx].AddActor2D(actor[idx])
renWin.AddRenderer(imager[idx])
imager[0].SetViewport(0, .5, .33, 1)
imager[1].SetViewport(.33, .5, .66, 1)
imager[2].SetViewport(.66, .5, 1, 1)
imager[3].SetViewport(0, 0, .33, .5)
imager[4].SetViewport(.33, 0, .66, .5)
imager[5].SetViewport(.66, 0, 1, .5)
renWin.SetSize(768, 512)
# render and interact with data
iRen = vtk.vtkRenderWindowInteractor()
iRen.SetRenderWindow(renWin);
renWin.Render()
img_file = "TestAllLogic.png"
vtk.test.Testing.compareImage(iRen.GetRenderWindow(), vtk.test.Testing.getAbsImagePath(img_file), threshold=25)
vtk.test.Testing.interact()
开发者ID:151706061,项目名称:VTK,代码行数:75,代码来源:TestAllLogic.py
示例16: testThreshold
def testThreshold(self):
# This script is for testing the 3D threshold filter.
# Image pipeline
renWin = vtk.vtkRenderWindow()
renWin.SetSize(192, 256)
reader = vtk.vtkImageReader()
reader.ReleaseDataFlagOff()
reader.SetDataByteOrderToLittleEndian()
reader.SetDataExtent(0, 63, 0, 63, 1, 93)
reader.SetDataSpacing(3.2, 3.2, 1.5)
reader.SetFilePrefix(VTK_DATA_ROOT + "/Data/headsq/quarter")
reader.SetDataMask(0x7fff)
outputtype = ["SignedChar", "UnsignedChar", "Long", "UnsignedLong", "Int", "UnsignedInt",
"Short", "UnsignedShort", "Double", "Float", "Double", "Float"]
replacein = ["ReplaceInOn", "ReplaceInOff"]
replaceout = ["ReplaceOutOn", "ReplaceOutOff"]
thresholds = ["ThresholdByLower(800)", "ThresholdByUpper(1200)", "ThresholdBetween(800, 1200)"]
thresh = list()
map = list()
act = list()
ren = list()
k = 0
for rin in replacein:
for rout in replaceout:
for t in thresholds:
thresh.append(vtk.vtkImageThreshold())
thresh[k].SetInValue(2000)
thresh[k].SetOutValue(0)
eval('thresh[k].' + rin + '()')
eval('thresh[k].' + rout + '()')
thresh[k].SetInputConnection(reader.GetOutputPort())
eval('thresh[k].' + t)
eval('thresh[k].SetOutputScalarTypeTo' + outputtype[k] + '()')
map.append(vtk.vtkImageMapper())
map[k].SetInputConnection(thresh[k].GetOutputPort())
if k < 3:
map[k].SetColorWindow(255)
map[k].SetColorLevel(127.5)
else:
map[k].SetColorWindow(2000)
map[k].SetColorLevel(1000)
act.append(vtk.vtkActor2D())
act[k].SetMapper(map[k])
ren.append(vtk.vtkRenderer())
ren[k].AddActor2D(act[k])
renWin.AddRenderer(ren[k])
k += 1
ren[0].SetViewport(0, 0, .33333, .25)
ren[1].SetViewport(.33333, 0, .66667, .25)
ren[2].SetViewport(.66667, 0, 1, .25)
ren[3].SetViewport(0, .25, .33333, .5)
ren[4].SetViewport(.33333, .25, .66667, .5)
ren[5].SetViewport(.66667, .25, 1, .5)
ren[6].SetViewport(0, .5, .33333, .75)
ren[7].SetViewport(.33333, .5, .66667, .75)
ren[8].SetViewport(.66667, .5, 1, .75)
ren[9].SetViewport(0, .75, .33333, 1)
ren[10].SetViewport(.33333, .75, .66667, 1)
ren[11].SetViewport(.66667, .75, 1, 1)
# render and interact with data
iRen = vtk.vtkRenderWindowInteractor()
iRen.SetRenderWindow(renWin);
renWin.Render()
img_file = "TestThreshold.png"
vtk.test.Testing.compareImage(iRen.GetRenderWindow(), vtk.test.Testing.getAbsImagePath(img_file), threshold=25)
vtk.test.Testing.interact()
开发者ID:151706061,项目名称:VTK,代码行数:83,代码来源:TestThreshold.py
示例17: testWipe
def testWipe(self):
# Image pipeline
renWin = vtk.vtkRenderWindow()
image1 = vtk.vtkImageCanvasSource2D()
image1.SetNumberOfScalarComponents(3)
image1.SetScalarTypeToUnsignedChar()
image1.SetExtent(0, 79, 0, 79, 0, 0)
image1.SetDrawColor(255, 255, 0)
image1.FillBox(0, 79, 0, 79)
image1.Update()
image2 = vtk.vtkImageCanvasSource2D()
image2.SetNumberOfScalarComponents(3)
image2.SetScalarTypeToUnsignedChar()
image2.SetExtent(0, 79, 0, 79, 0, 0)
image2.SetDrawColor(0, 255, 255)
image2.FillBox(0, 79, 0, 79)
image2.Update()
mapper = vtk.vtkImageMapper()
mapper.SetInputConnection(image1.GetOutputPort())
mapper.SetColorWindow(255)
mapper.SetColorLevel(127.5)
actor = vtk.vtkActor2D()
actor.SetMapper(mapper)
imager = vtk.vtkRenderer()
imager.AddActor2D(actor)
renWin.AddRenderer(imager)
wipes = ["Quad", "Horizontal", "Vertical", "LowerLeft", "LowerRight", "UpperLeft", "UpperRight"]
wiper = dict()
mapper = dict()
actor = dict()
imagers = dict()
for wipe in wipes:
wiper.update({wipe:vtk.vtkImageRectilinearWipe()})
wiper[wipe].SetInput1Data(image1.GetOutput())
wiper[wipe].SetInput2Data(image2.GetOutput())
wiper[wipe].SetPosition(20, 20)
eval('wiper[wipe].SetWipeTo' + wipe + '()')
mapper.update({wipe:vtk.vtkImageMapper()})
mapper[wipe].SetInputConnection(wiper[wipe].GetOutputPort())
mapper[wipe].SetColorWindow(255)
mapper[wipe].SetColorLevel(127.5)
actor.update({wipe:vtk.vtkActor2D()})
actor[wipe].SetMapper(mapper[wipe])
imagers.update({wipe:vtk.vtkRenderer()})
imagers[wipe].AddActor2D(actor[wipe])
renWin.AddRenderer(imagers[wipe])
imagers["Quad"].SetViewport(0, .5, .25, 1)
imagers["Horizontal"].SetViewport(.25, .5, .5, 1)
imagers["Vertical"].SetViewport(.5, .5, .75, 1)
imagers["LowerLeft"].SetViewport(.75, .5, 1, 1)
imagers["LowerRight"].SetViewport(0, 0, .25, .5)
imagers["UpperLeft"].SetViewport(.25, 0, .5, .5)
imagers["UpperRight"].SetViewport(.5, 0, .75, .5)
imager.SetViewport(.75, 0, 1, .5)
renWin.SetSize(400, 200)
# render and interact with data
iRen = vtk.vtkRenderWindowInteractor()
iRen.SetRenderWindow(renWin);
renWin.Render()
img_file = "TestWipe.png"
vtk.test.Testing.compareImage(iRen.GetRenderWindow(), vtk.test.Testing.getAbsImagePath(img_file), threshold=25)
vtk.test.Testing.interact()
开发者ID:151706061,项目名称:VTK,代码行数:80,代码来源:TestWipe.py
示例18: testAllMaskBits
def testAllMaskBits(self):
# This script calculates the luminance of an image
renWin = vtk.vtkRenderWindow()
# Image pipeline
image1 = vtk.vtkTIFFReader()
image1.SetFileName(VTK_DATA_ROOT + "/Data/beach.tif")
# "beach.tif" image contains ORIENTATION tag which is
# ORIENTATION_TOPLEFT (row 0 top, col 0 lhs) type. The TIFF
# reader parses this tag and sets the internal TIFF image
# orientation accordingly. To overwrite this orientation with a vtk
# convention of ORIENTATION_BOTLEFT (row 0 bottom, col 0 lhs ), invoke
# SetOrientationType method with parameter value of 4.
image1.SetOrientationType(4)
shrink = vtk.vtkImageShrink3D()
shrink.SetInputConnection(image1.GetOutputPort())
shrink.SetShrinkFactors(2, 2, 1)
operators = ["ByPass", "And", "Nand", "Xor", "Or", "Nor"]
operator = dict()
mapper = dict()
actor = dict()
imager = dict()
for idx, op in enumerate(operators):
if op != "ByPass":
operator.update({idx: vtk.vtkImageMaskBits()})
operator[idx].SetInputConnection(shrink.GetOutputPort())
eval('operator[' + str(idx) + '].SetOperationTo' + op + '()')
operator[idx].SetMasks(255, 255, 0)
mapper.update({idx: vtk.vtkImageMapper()})
if op != "ByPass":
mapper[idx].SetInputConnection(operator[idx].GetOutputPort())
else:
mapper[idx].SetInputConnection(shrink.GetOutputPort())
mapper[idx].SetColorWindow(255)
mapper[idx].SetColorLevel(127.5)
actor.update({idx: vtk.vtkActor2D()})
actor[idx].SetMapper(mapper[idx])
imager.update({idx: vtk.vtkRenderer()})
imager[idx].AddActor2D(actor[idx])
renWin.AddRenderer(imager[idx])
column = 0
row = 0
deltaX = 1.0 / 3.0
deltaY = 1.0 / 2.0
for idx in range(len(operators)):
imager[idx].SetViewport(column * deltaX, row * deltaY, (column + 1) * deltaX, (row + 1) * deltaY)
column += 1
if column > 2:
column = 0
row += 1
renWin.SetSize(384, 256)
# render and interact with data
iRen = vtk.vtkRenderWindowInteractor()
iRen.SetRenderWindow(renWin);
renWin.Render()
img_file = "TestAllMaskBits.png"
vtk.test.Testing.compareImage(iRen.GetRenderWindow(), vtk.test.Testing.getAbsImagePath(img_file), threshold=25)
vtk.test.Testing.interact()
开发者ID:timkrentz,项目名称:SunTracker,代码行数:78,代码来源:TestAllMaskBits.py
示例19: testAllBlendsFloat
def testAllBlendsFloat(self):
# This script blends images that consist of float data
renWin = vtk.vtkRenderWindow()
renWin.SetSize(512, 256)
# Image pipeline
inputImage = vtk.vtkTIFFReader()
inputImage.SetFileName(VTK_DATA_ROOT + "/Data/beach.tif")
# "beach.tif" image contains ORIENTATION tag which is
# ORIENTATION_TOPLEFT (row 0 top, col 0 lhs) type. The TIFF
# reader parses this tag and sets the internal TIFF image
# orientation accordingly. To overwrite this orientation with a vtk
# convention of ORIENTATION_BOTLEFT (row 0 bottom, col 0 lhs ), invoke
# SetOrientationType method with parameter value of 4.
inputImage.SetOrientationType(4)
inputImage2 = vtk.vtkBMPReader()
inputImage2.SetFileName(VTK_DATA_ROOT + "/Data/masonry.bmp")
# shrink the images to a reasonable size
shrink1 = vtk.vtkImageShrink3D()
shrink1.SetInputConnection(inputImage.GetOutputPort())
shrink1.SetShrinkFactors(2, 2, 1)
shrink2 = vtk.vtkImageShrink3D()
shrink2.SetInputConnection(inputImage2.GetOutputPort())
shrink2.SetShrinkFactors(2, 2, 1)
color = vtk.vtkImageShiftScale()
color.SetOutputScalarTypeToFloat()
color.SetShift(0)
color.SetScale(1.0 / 255)
color.SetInputConnection(shrink1.GetOutputPort())
backgroundColor = vtk.vtkImageShiftScale()
backgroundColor.SetOutputScalarTypeToFloat()
backgroundColor.SetShift(0)
backgroundColor.SetScale(1.0 / 255)
backgroundColor.SetInputConnection(shrink2.GetOutputPort())
# create a greyscale version
luminance = vtk.vtkImageLuminance()
luminance.SetInputConnection(color.GetOutputPort())
backgroundLuminance = vtk.vtkImageLuminance()
backgroundLuminance.SetInputConnection(backgroundColor.GetOutputPort())
# create an alpha mask
alpha = vtk.vtkImageThreshold()
alpha.SetInputConnection(luminance.GetOutputPort())
alpha.ThresholdByLower(0.9)
alpha.SetInValue(1.0)
alpha.SetOutValue(0.0)
# make luminanceAlpha and colorAlpha versions
luminanceAlpha = vtk.vtkImageAppendComponents()
luminanceAlpha.AddInputConnection(luminance.GetOutputPort())
luminanceAlpha.AddInputConnection(alpha.GetOutputPort())
colorAlpha = vtk.vtkImageAppendComponents()
colorAlpha.AddInputConnection(color.GetOutputPort())
colorAlpha.AddInputConnection(alpha.GetOutputPort())
foregrounds = ["luminance", "luminanceAlpha", "color", "colorAlpha"]
backgrounds = ["backgroundColor", "backgroundLuminance"]
deltaX = 1.0 / 4.0
deltaY = 1.0 / 2.0
blend = dict()
mapper = dict()
actor = dict()
imager = dict()
for row, bg in enumerate(backgrounds):
for column, fg in enumerate(foregrounds):
blend.update({bg:{fg:vtk.vtkImageBlend()}})
blend[bg][fg].AddInputConnection(eval(bg + '.GetOutputPort()'))
if bg == "backgroundColor" or fg == "luminance" or fg == "luminanceAlpha":
blend[bg][fg].AddInputConnection(eval(fg + '.GetOutputPort()'))
blend[bg][fg].SetOpacity(1, 0.8)
mapper.update({bg:{fg:vtk.vtkImageMapper()}})
mapper[bg][fg].SetInputConnection(blend[bg][fg].GetOutputPort())
mapper[bg][fg].SetColorWindow(1.0)
mapper[bg][fg].SetColorLevel(0.5)
actor.update({bg:{fg:vtk.vtkActor2D()}})
actor[bg][fg].SetMapper(mapper[bg][fg])
imager.update({bg:{fg:vtk.vtkRenderer()}})
imager[bg][fg].AddActor2D(actor[bg][fg])
#.........这里部分代码省略.........
开发者ID:151706061,项目名称:VTK,代码行数:101,代码来源:TestAllBlendsFloat.py
示例20:
blend.update({bg:{fg:vtk.vtkImageBlend()}})
blend[bg][fg].AddInputConnection(eval(bg + '.GetOutputPort()'))
blend[bg][fg].SetBlendModeToCompound()
if bg == "backgroundAlpha" or bg == "backgroundColor":
blend[bg][fg].AddInputConnection(eval(fg + '.GetOutputPort()'))
if bg == "backgroundAlpha":
blend[bg][fg].SetCompoundAlpha(True)
blend[bg][fg].SetOpacity(0, 0.5)
blend[bg][fg].SetOpacity(1, 0.5)
else:
blend[bg][fg].SetOpacity(1, 0.8)
elif fg == "luminance" or fg == "luminanceAlpha":
blend[bg][fg].AddInputConnection(eval(fg + '.GetOutputPort()'))
blend[bg][fg].SetOpacity(1, 0.8)
mapper.update({bg:{fg:vtk.vtkImageMapper()}})
mapper[bg][fg].SetInputConnection(blend[bg][fg].GetOutputPort())
mapper[bg][fg].SetColorWindow(255)
mapper[bg][fg].SetColorLevel(127.5)
actor.update({bg:{fg:vtk.vtkActor2D()}})
actor[bg][fg].SetMapper(mapper[bg][fg])
imager.update({bg:{fg:vtk.vtkRenderer()}})
|
请发表评论