VTK提供切片(clip)功能的相关类:vtkExtractVOI, vtkImageClip。vtkExtractVOI可以被用于体的重采样,vtkImageClip则不能。
vtkExtractGrid和vtkExtractVOI的对比:
vtkExtractGrid : public vtkStructuredGridAlgorithm
vtkExtractGrid is a filter that selects a portion of an input structured grid dataset, or subsamples an input dataset.

vtkExtractVOI : public vtkImageAlgorithm
vtkExtractVOI is a filter that selects a portion of an input structured points dataset, or subsamples an input dataset.

最初效果:




代码出自:Examples/ImageProcessing/Tcl/Contours2D.tcl

package require vtk
package require vtkinteraction

# Quadric definition. This is a type of implicit function. Here the
# coefficients to the equations are set.
vtkQuadric quadric
  quadric SetCoefficients .5 1 .2 0 .1 0 0 .2 0 0

vtkSampleFunction sample
  sample SetSampleDimensions 30 30 30
  sample SetImplicitFunction quadric
  sample ComputeNormalsOff

vtkExtractVOI extract
  extract SetInputConnection [sample GetOutputPort]
  extract SetVOI 0 29 0 29 15 15
  extract SetSampleRate 1 2 3

vtkContourFilter contours
  contours SetInputConnection [extract GetOutputPort]
  contours GenerateValues 13 0.0 1.2

vtkPolyDataMapper contMapper
  contMapper SetInputConnection [contours GetOutputPort]
  contMapper SetScalarRange 0.0 1.2

vtkActor contActor
  contActor SetMapper contMapper

vtkOutlineFilter outline
  outline SetInputConnection [sample GetOutputPort]

vtkPolyDataMapper outlineMapper
  outlineMapper SetInputConnection [outline GetOutputPort]

vtkActor outlineActor
  outlineActor SetMapper outlineMapper
  eval [outlineActor GetProperty] SetColor 0 0 0

vtkRenderer ren1
vtkRenderWindow renWin
    renWin AddRenderer ren1
vtkRenderWindowInteractor iren
    iren SetRenderWindow renWin

ren1 SetBackground 1 1 1
ren1 AddActor contActor
ren1 AddActor outlineActor

# Zoom in a little bit. Associate the Tk interactor popup with a user
# keypress-u (the UserEvent).
ren1 ResetCamera
[ren1 GetActiveCamera] Zoom 1.5
iren AddObserver UserEvent {wm deiconify .vtkInteract}
iren Initialize
iren Start

# Don't show the root Tk window "."
wm withdraw .

去除采样比的设置:# extract SetSampleRate 1 2 3




现在在Z方向上也全部重采样

extract SetVOI 0 29 0 29 15 15
=>
extract SetVOI 0 29 0 29 0 29




增加等值面的数量,让其向一个“体”靠拢。

contours GenerateValues 13 0.0 1.2
=>
contours GenerateValues 130 0.0 1.2




关于例子的三元方程,之前的文章也有介绍:
vtk教程中的三元二次方程

分类: TCL

发表评论

电子邮件地址不会被公开。 必填项已用*标注