三維繪製包括面繪製和體繪製。體繪製可以提供最接近人眼視覺的繪製效果。體繪製的方法包括:
raycasting
splatting
shear warp
texture based volume rendering
其中raycasting是最常用的方法之一。包括四個步驟:ray casting, sampling, shading and composition。具體的描述如下:
在raycasting演算法中,主要涉及到的是transfer function的概念。transfer function通常被用來對不同密度或者不同位置的體素單元加上顏色和透明度屬性。transfer function的例項如下:
在vtk中,實現volume rendering的程式示例如下:
renwin->addrenderer(ren);
vtksmartpointeriren =
vtksmartpointer::new();
iren->setrenderwindow(renwin);
// finally, add the volume to the renderer
ren->addviewprop(volume);
// set up an initial view of the volume. the focal point will be the
// center of the volume, and the camera position will be 400mm to the
// patient's left (which is our right).
vtkcamera *camera = ren->getactivecamera();
double *c = volume->getcenter();
camera->setfocalpoint(c[0], c[1], c[2]);
camera->setposition(c[0] + 400, c[1], c[2]);
camera->setviewup(0, 0, -1);
// increase the size of the render window
renwin->setsize(640, 480);
// interact with the data.
iren->initialize();
iren->start();
return exit_success;}
結果如下:
體繪製之光線投射演算法(附原始碼)
一 原理 levoy在1988年提出了光線投射 ray casting 演算法 1 其基本原理是 從螢幕上每乙個畫素點出發,沿著視線方向發射出一條光線,當這條光線穿過體資料時,沿著光線方向等距離取樣,利用插值計算出取樣點的顏色值和不透明度 接著按照從前到後或從後到前的順序對光線上的取樣點進行合成,計...
體繪製技術小結
vtk主要提供了三種體繪製技術 vtk最初是針對醫療領域的應用而 設計的,所以對於醫療的視覺化方面,如處理ct的掃瞄 資料等,具有強大的功能。它將在視覺化過程中經常遇到的細節遮蔽起來,並封裝了一些常用的視覺化演算法,如將麵繪製中常用的mc marching cubes 演算法和體繪製中常用的光線投射...
OpenGL WebGL 繪製立方體
include 繪製立方體 將立方體的八個頂點儲存到乙個陣列裡面 static const float vertex list 3 將要使用的頂點的序號儲存到乙個陣列裡面 static const glint index list 2 繪製立方體 void drawcube void glend s...