Pipelines@Volume Rendering
vtkImageData
topologically and geometrically regular array of data
vtkImageData is a data object that is a concrete implementation of vtkDataSet. vtkImageData represents a geometric structure that is a topological and geometrical regular array of points. Examples include volumes (voxel data) and pixmaps.
vtkFixedPointVolumeRayCastCompositeHelper -- A helper that generates composite images for the volume ray cast mapper. It will generate composite images using an alpha blending operation.
vtkFixedPointVolumeRayCastCompositeGOHelper -- A helper that generates composite images for the volume ray cast mapper.
想要使用VTK,作出Volume Render的應用程式(最終還是要作出Parallel化的版本),其間的Pipeline應為:
- 讀資料: 使用vtkImageReader類別,作出 ImgReader物件,然後使用SetFileName, SetDataScalarTypeToFloat, SetDataByteOrderToBigEndian, SetFileDimensionality, SetDataExtent, SetDataSpacing, SetHeaderSize..., 最後再用 Update來讀入這些圖形檔案(png, jpeg, dicom...)、或是raw-data(.vtk)的資訊。
- 設定VolRndr物件的Property: 使用vtkVolumeProperty作出VolProperty物件,然後使用
VolProperty->SetScalarOpacity(opacity); VolProperty->SetColor(color);
呼叫,加入Color、或是Piecewise的屬性。 - Piecewise屬性: 使用vtkPiecewiseFunction作出Opacity物件,然後使用
Opacity->AddPoint(500, 0.1)
呼叫,加入各點不透明度的資訊。 - Color屬性: 使用vtkColorTransferFunction作出Color物件,然後使用
Color->AddRGBPoint(0, 0.3, 0.3, 1.0)
呼叫,加入RGB顏色的資訊。 - 融合屬性: 使用vtkVolumeRayCastCompositeFunction作出compositeFun物件,目的是為了融合之前所作出Color屬性或是Piecewise屬性。
- 產生Geometry資訊: 使用vtkVolumeRayCastMapper,或是vtkFixedPointVolumeRayCastMapper作出VolMapper物件,兩者的區別,請看以下的說明:
VolMapper->SetVolumeRayCastFunction(Composite); //將Color、Piecewise的屬性,融合於VolProperty物件。 VolMapper->SetInput(ImgReader->GetOutput()); //將ImgReader讀入的Datasets轉成Geometry資訊。
- 使用vtkVolume作出VolRndr:
VolRndr->SetMapper(VolMapper); //加入VolMapper的幾何資訊 VolRndr->SetProperty(VolProperty); //加入VolProperty的顏色、Piecewise屬性。
- 使用vtkRenderer作出Rndr物件:
Rndr->AddVolume(VolRndr); //在記憶體中繪製VolRndr物件 Rndr->SetBackground(1., 1., 1.); //設定Rndr物件的屬性
- 使用vtkRenderWindow作出繪製視窗RndrWin物件:
RndrWin->AddRenderer(Rndr); //繪製視窗加入render物件 RndrWin->SetSize(500,500); //設定視窗大小屬性 RndrWin->SetInteractor(InterRen); //也可以加入繒製互動式視窗物件InterRen
- 使用vtkRenderWindowInteractor作出繪製互動視窗InterRen
RndrWin->Render(); //開始繪製 InterRen->Start(); //開始互動式視窗
vtkVolumeRayCastMapper vs. vtkFixedPointVolumeRayCastMapper
vtkVolumeRayCastMapper可以用來作isosurface,而處理的資料型態為unsigned char或是unsigned short。 vtkFixedPointVolumeRayCastMapper的資料型態為short或是more than one component,處理的範圍為unsigned char到double。Features of vtkFixedPointVolumeRayCastMapper
Space leaping is performed by creating a sub-sampled volume. 4x4x4 cells in the original volume are represented by a min, max, and combined gradient and flag value. The min max volume has three unsigned shorts per 4x4x4 group of cells from the original volume - one reprenting the minumum scalar index (the scalar value adjusted to fit in the 15 bit range), the maximum scalar index, and a third unsigned short which is both the maximum gradient opacity in the neighborhood (an unsigned char) and the flag that is filled in for the current lookup tables to indicate whether this region can be skipped.