Direct Volume Rendering Han-Wei Shen The Ohio State University
Volume Rendering • A method to visualize the en?re 3D data set by simula?ng light transport across the volume • A 2D projec?on of 3D discrete samples
Direct Volume Rendering • Simulate light transport through a con?nuous volume • Data are interpolated from the samples at the grid points • Op?cal proper?es such as colors and opaci?es are assigned to the interpolated data • Op?cal proper?es must be integrated along each viewing ray X c1 c2 c3
What will we cover? • Part 1: Op?cal Model – hLps://www.youtube.com/watch?v=hiaHlTLN9TE • Part 2: Discrete Implementa?on – hLps://www.youtube.com/watch?v=M5WHEkbGhEE • Part 3: Live Demo and Try Yourself – hLps://www.youtube.com/watch?v=IqIvK6EiBz8
Op?cal Model Par?cipa?ng medium (the voxels) can absorb, emit, or both absorb and emit light How much light will reach the eye? • Absorp?on Model • Emission Model • Absorp?on + Emission
Absorp?on Only • The simplest par?cipa?ng medium • Consists of perfectly black par?cles that absorb all the light that they intercept • Assume – A small cylindrical slab with a base area E and thickness Δ s – Number of par?cles per unit volume = ρ – each par?cle has an area of A = π r 2 • Total number of par?cles = E Δ s ρ Δ s • Total area occluded by par?cles = A E Δ s ρ E A = π r 2 • The frac?on of occluded area = AE Δ s ρ / E = A Δ s ρ d I(s) = - I(s) x A Δ s ρ (s) = - A ρ (s) I (s) Solve this ODE ds Δ s
Absorp?on Only • The simplest par?cipa?ng medium • Consists of perfectly black par?cles that absorb all the light that they intercept • Assume – A small cylindrical slab with a base area E and thickness Δ s – Number of par?cles per unit volume = ρ – each par?cle has an area of A = π r 2 Δ s d I Solve this ODE = - A ρ (s) I (s) ds E A = π r 2 R s R s 0 ρ ( t ) Adt = I 0 × e − 0 τ ( t ) dt I ( s ) = I 0 × e −
Absorp?on Only Δ s R s R s 0 ρ ( t ) Adt = I 0 × e − E A = π r 2 0 τ ( t ) dt I ( s ) = I 0 × e − I 0 : ex?nc?on coefficient ρ ( t ) A = τ ( t ) I 0 = Ini?al light intensity R s Can be seen as the transparency, or 0 τ ( t ) dt e − 1 – opacity of the medium from 0 to s
Emission Only • Each par?cle will glow diffusively with an intensity C • In a small cylindrical slab, the Δ s E A = π r 2 total area occupied by the par?cles is AE Δ s ρ • So the glow flux will be CAE Δ s ρ • Then the glow per unit area is CAE Δ s ρ /E = CA Δ s ρ d I Solve this ODE = C(s) A ρ (s) = C(s) τ (s) = g(s) ds
Emission Only • Each par?cle will glow diffusively with an intensity C • In a small cylindrical slab, the Δ s E A = π r 2 total area occupied by the par?cles is AE Δ s ρ • So the glow flux will be CAE Δ s ρ • Then the glow per unit area is CAE Δ s ρ /E = CA Δ s ρ d I Solve this ODE = C(s) A ρ (s) = C(s) τ (s) = g(s) ds Z s Z s I ( s ) = I 0 + g ( t ) dt = I 0 + C ( t ) τ ( t ) dt 0 0
Emission plus Absorp?on • Simply add emission and absorp?on together Δ s d I E = C(s) τ (s) - A ρ (s) I (s) = g(s) – τ (s)I(s) A = π r 2 ds emission absorp?on Solve this ODE Z R D R D τ ( t ) dt + τ ( t ) dt ds D I ( D ) = I 0 × e − 0 g ( s ) e − 0 s S = 0 S = D I 0
Put It All Together S = 0 S = D I 0 • Absorp?on only: R s 0 ρ ( t ) Adt = I 0 × e − R s 0 τ ( t ) dt I ( s ) = I 0 × e − • Emission only: Z s Z s I ( s ) = I 0 + g ( t ) dt = I 0 + C ( t ) τ ( t ) dt 0 0 • Emission plus absorp?on: Z R D R D τ ( t ) dt + τ ( t ) dt ds D I ( D ) = I 0 × e − 0 g ( s ) e − 0 s
Look More Closely Z R D R D τ ( t ) dt + τ ( t ) dt ds D I ( D ) = I 0 × e − 0 g ( s ) e − s 0 : background light I 0 τ ( t ) : ex?nc?on coefficient at t , related to the rate that light is occluded : total distance light will travel D R D τ ( t ) dt : transparency of medium between 0 and D e − 0 R D τ ( t ) dt = α : opacity of medium between 0 and D 1 − e − 0 : source term at point s, typically derived from the data value g ( s ) S = 0 S = D I 0
Discrete Implementa?on • Numerical integra?on: Z D i = n X h ( x ) dx = h ( x i ) ∆ x 0 i =1 (Riemann Sum) X 0 X 1 X 2 X 3 X 4 X 5 … Δ x = X i – X i-1 R D τ ( t ) dt = e − P i = n i =1 τ ( t t ) ∆ t i e − 0 = e − P i = n Y i =1 τ ( i ∆ x ) ∆ x = e − τ ( i ∆ x ) ∆ x i = n R D Y τ ( t ) dt = α = (1 − α i ) (Remember ) 1 − e − 0 i =1
Discrete Implementa?on Z R D R D τ ( t ) dt + τ ( t ) dt ds D I ( D ) = I 0 × e − 0 g ( s ) e − s 0 i = n n i = n X Y Y (1 − α i ) (1 − α i ) I 0 g i × i =1 j = i +1 i =1 = g n + (1- α n )(g n -1+(1- α n-1 )(g n-2 + (1- α n-2 (…. (1- α 2 )(g 2 +(1- α 1 )(g 1 +I 0 )))))…))))) This is called - Back to Front Composi?ng S = 0 S = D I 0 g 1 g 2 g 3 g 4 g 5 g 6 g 7 g 8 g 9 g 10 … α 1 α 2 α 3 α 4 α 5 α 6 α 7 α 8 α 9 α 10 …
Discrete Implementa?on Z R D R D τ ( t ) dt + τ ( t ) dt ds D I ( D ) = I 0 × e − 0 g ( s ) e − 0 s i = n n i = n X Y Y ( ) (1 − α i ) (1 − α i ) I 0 g i × i =1 j = i +1 i =1 = g n + (1- α n )(g n-1 +(1- α n-1 )(g n-2 + (1- α n-2 (…. (1- α 2 )(g 2 +(1- α 1 )(g 1 +I 0 )))))…))))) S = 0 S = D I 0 g 1 g 2 g 3 g 4 g 5 g 6 g 7 g 8 g 9 g 10 … α 1 α 2 α 3 α 4 α 5 α 6 α 7 α 8 α 9 α 10 …
Ray Cas?ng Algorithm • For each pixel – Cast a ray into the volume – Linearly interpolate data values from cell (voxel) corners – Convert the data values to op?cal proper?es (color and opacity) – Composite the op?cal proper?es – Return the final color g1 g2 X g3
Shading and Classifica?on • Shading: computer a color for every sample in the volume • Classifica?on: computer an opacity for every sample in the volume f(x i ) c(x i ), a(x i ) • This is ooen done through a table (transfer func?on) lookup
Shading • Use the Phong illumina?on model illumina?on = ambient + diffuse + specular = C(x i ) x I a + C(x i ) x I d x (N.L) + C(x i ) x I s x (R.V) n C(x i ) : color of sample i I a , I d , I s : light’s ambient, diffuse, and specular colors (usually set as white) N L N: normal at sample i R V: vector from sample point to eye φ V L: light vector, from sample to light source θ θ R: reflec?on vector of light vector Sample i n: shininess
Normal Es?ma?on • How to compute the sample normal N? – Normal: a vector that is perpendicular to the local surface, which is the gradient of the sample point 1. Compute the gradient G at the cell corners using central difference 2. Linearly interpolate the gradients
Classifica?on • Classifica?on: mapping from data values to opaci?es Z R D R D τ ( t ) dt + τ ( t ) dt ds D I ( D ) = I 0 × e − 0 g ( s ) e − 0 s i = n n i = n X Y Y (1 − α i ) (1 − α i ) I 0 g i × i =1 j = i +1 i =1 – Region of interest: high opacity – Rest: translucent or transparent • The opacity func?on, or called transfer func?on, is given by the user
Ray Sampling • Sample the volume at discrete points along the ray • Perform tri-linear interpola?on to get c1 the sample values • Look up the transfer func?on to c2 get the color and opacity • Composi?ng the color/opacity c3 (front-to-back or back-to-front)
Back-to-Front Composi?ng The ini?al pixel color = Black Back-to-Front composi?ng: c1 use ‘under’ operator C = C1 ‘under’ background c2 C = C2 ‘under’ C C = C3 ‘under’ C c3 … C out = C in * (1- α (x)) + C(x)* α (x) (this is the alpha blending formula)
Front-to-Back Composi?ng Front-to-Back composi?ng: use ‘over’ operator c1 C = background ‘over’ C1 c2 C = C ‘over’ C2 C = C ‘over’ C3 c3 … C out = C in + C(x) α (x) *(1- α in ); α out = α in + α (x) *(1- α in )
Put Everything Together RGBA Ray-Cas?ng(pos, dir) { color_acc = 0; opacity_acc = 0; t = entry_pos; max_t = exit_pos; while (t < max_t) { sample = get_sample(pos+dir*t); X dir pos color, opacity = trans_func(sample); c1 c2 c3 color_acc += (1-opacity_acc)*color*opacity; opacity_acc += (1-opacity_acc)*opacity; t++; } return color_acc, opacity_acc; }
Live Demo and Try Yourself
Live Demo and Try Yourself • Want to try yourself? – ParaView: • hLps://www.paraview.org/download/ – Volume Data: • hLp://www9.informa?k.uni-erlangen.de/External/vollib/ – WebGL implementa?ons of volume rendering: • hLp://www.lebarba.com/WebGL/Index.html • hLps://github.com/FNNDSC/ami
Recommend
More recommend