沿着軸方向切割體數據。
vtkImageReslice 是幾何圖形過濾器中的瑞士軍刀。他可以排列,旋轉,翻轉,縮放,重新采樣,變形, 還有隨意再任何效率與圖像質量組合下,渲染圖像。簡單的操作,像排列,重新采樣和渲染高效功能,與被人所熟知的vtkImagePermute、 vtkImageResample 和 vtkImagePad一樣。有一些任務,vtkImageReslice更適合做這些事情。
1)對一個圖像應用簡單的旋轉,縮放和平移。有一個更好的注意是,先使用vtkImageChangeInformation,把圖像的坐標系原點更新到圖像中心點,以便尺度和旋轉發生中心而不是環繞圖像的左下角。
2)通過方法SetInformationInput對一個數據集重新采樣,以匹配另一個數據集。例如,比較兩個圖像或者組合兩幅圖像。可以我不在同一個坐標系空間上的2幅圖像,同時通過方法SetResliceTransform 應用線性或非線性變換。
3)從一個體數據中提取圖像切片卷。最方便的方法來執行此操作是使用 SetResliceAxesDirectionCosines() 指定切片的方向。方向余弦形式給出 x、 y 和 z 軸的輸出向量。SetOutputDimensionality(2) 用於指定的方法想要輸出一個切片,而不是一個卷。SetResliceAxesOrigin()方法,設置切片將經過的該origin空間點。你也可以同時使用ResliceAxes 和ResliceTransform ,為了從體數據中導出切片序列,你需要應用變換信息。transformation
應用實例:
#-*- coding: UTF-8 -*- #------------------------------------------------------------------------------- # Name: 模塊2 # Purpose: # # Author: ankier # # Created: 07-01-2013 # Copyright: (c) Ankier 2013 # Licence: <your licence> #------------------------------------------------------------------------------- from ActorFactory import ActorFactory from vtk import * from glo import * class ResliceActorFactory(ActorFactory): def __init__(self): ActorFactory.__init__(self) #定義一塊板子 self.__PlaneSource = vtkPlaneSource() self.__PlaneSource.SetOrigin(-50, -50, 0) self.__PlaneSource.SetPoint1(50, -50 , 0) self.__PlaneSource.SetPoint2(-50 , 50 , 0) self.__PlaneSource.SetXResolution(50) self.__PlaneSource.SetYResolution(50) self.__Input = None #定義圖像切片類 self.__ImageReslice = vtkImageReslice() globalInstance = Global.GetInstance() transform = globalInstance.GetOrthoViewFrame().GetOrthoPlanesFactory().GetAxialPlane()._Transform print transform self.__ImageReslice.SetResliceTransform(transform) self.__ImageReslice.InterpolateOn() self.__ImageReslice.SetOptimization(2) self.__ImageReslice.SetBackgroundLevel(1023) self.__ImageReslice.SetInterpolationModeToLinear() self.__ImageReslice.SetOutputDimensionality(2) self.__LookupTable = vtkLookupTable() self.__LookupTable.SetNumberOfTableValues(256) self.__LookupTable.Build() for i in range(256): self.__LookupTable.SetTableValue(i, i/255.0, i/255.0, i/255.0) self.__MapToColor = vtkImageMapToColors() self.__MapToColor.SetLookupTable(self.__LookupTable) self.__MapToColor.SetInputConnection(self.__ImageReslice.GetOutputPort()) #設置板子的紋理映射類 self.__TexturePlane= vtkTextureMapToPlane() self.__TexturePlane.SetInput(self.__PlaneSource.GetOutput()) #設置紋理類。 self.__Texture = vtkTexture() self.__Texture.InterpolateOn() self.__Texture.RepeatOff() # only necessary if interpolation is on #設置Poly Data,從紋理映射器重,得到被filter的輸出數據 self.__PolyDataMapper = vtkPolyDataMapper() self.__PolyDataMapper.SetInput(self.__TexturePlane.GetOutput()) def UpdateData(self): (min,max) = self.__Input.GetScalarRange() self.__LookupTable.SetTableRange(min,max) self.__ImageReslice.SetInput(self.__Input) self.__Texture.MapColorScalarsThroughLookupTableOff() self.__Texture.SetInput(self.__MapToColor.GetOutput()) def SetInput(self, input): self.__Input = input def _MakeActors(self): self.UpdateData() actor = self._NewActor() actor.SetMapper(self.__PolyDataMapper) actor.SetTexture(self.__Texture) return [actor]