5.2 Linear Gray Value Model
5.2.6 Realization
5.2.6.1 Incremental Algorithm for Generating LUT for Lin-
considered, 2D LUT which store for each couple of gray values Sf and Sb, at the
entry and exit point of a sampling interval, the re ection contribution in between. As we mentioned in the section 5.2.5, let decompose the range [0; D] in intervals [dj; dj+1]
such as: dj := 2j and j 2 [jmin::jmax]. First, Let us remaind the equation (2.3.17) in
chapter 2:
I(si) = I(si 1)e (si 1;si)+
Z si
si 1
q(s)e (s;si)ds (5.2.20)
By introducing the substitutions given in equations (2.3.18) and (2.3.19), the equation (5.2.20) can be rewritten by:
I(si) = I(si 1)i+ bi (5.2.21)
CHAPTER 5.2. LINEAR GRAY VALUE MODEL
j and bj as being respectively, the transparency and the color in between the
gray value interval [g 1; g]
I(si 1) as Cj 1(g 1): the re ected intensity (here shading color) at distance
dj 1
and I(si) as Cj(g): the re ected intensity at distance dj,
one can write the following recurrence relation: Cj(g) :=
(
0 ifj < jmin
Cj 1(g 1)j + bj 8j 2 [jmin::jmax]
(5.2.22) First, we initialize all re ection values for d = 0 to zero. Then, we start generating the 2D LUT in d direction for Sb = Sf. For this case, the results are generated
analytically as mentioned before and are stored into a temporary array T emp of size jmax jmin+ 1. Therefore, we keep Sf constant, increment Sb and repeat the process
until Sb = N (N the total size of the 2D LUT). Finally, we increment Sf and the
same procedure is reiterated until Sf = N. Given the recurrence relation (5.2.22), we
generate all the re ection values Cj(b) for j 2 [jmin::jmax]. The calculation of Cj(b)
involves the evaluation of:
1. j obtained from the opacity LUT at dj between Sb 1 and Sb by:
j = 1 opacity[j][b 1][b] (5.2.23)
2. bj read from the already precomputed 1D LUT color1d described in the previous
section.
CHAPTER 5.2. LINEAR GRAY VALUE MODEL
Figure 5.2: Incremental calculation of the color by compositing 3. Cj 1(g 1) read from the temporary array T emp.
Finally, we save the calculated value Cj(g) on T emp[j + 1], as shown in gure 5.2. A
pseudo-code of our incremental algorithm is given in algorithm 2.
Algorithm 2 Get Linear Color: Incremental algorithm for generating lookup tables when the gray value model is linear
for Sf = 0 to N do
for Sb = Sf to N do
if Sf = Sb then
for j = jmin to jmax do
Evaluate analytically color([j][Sf][Sb]);
T emp[j + 1] = color[j][Sf][Sb];
end for else
for j = jmin to jmax do
color[j][Sf][Sb] = composite(color1d[j][b]; T emp[j + 1]);
T emp[j + 1] = color[j][Sf][Sb];
end for end if end for end for
CHAPTER 5.3. QUADRATIC CASE
5.2.6.2 Algorithmic Complexity
Let ndbeing the number of distances interfering with the color LUT generation of size
n n. The above described algorithm requires, for each axis dj, nd multiplications
and additions. Thus, along the axis Sb, the number of operations needed is: nd i
such as: Sb 2 [n i; n] with i 2 [0::n 1]. Finally, along the axis Sf, the number
of operations required is: Pn 1i=0 ndi = ndn(n 1)2 n2. Therefore, the complexity of
our incremental algorithm is O(n2). Thus, our algorithm is better than the O(n3)
Lum's algorithm [38]. In addition, we perform the computations for dierent interval lengths. Thus, we addressed the problem of table generation speed. It is important that the computation of the lookup tables be ecient so that the transfer function may be interactively modied.
5.3
Quadratic Case
5.3.1
Motivations
Most techniques for the visualization of volume data require appropriate modeling. Exact analytic solution cannot be calculated, but approximated. The pre-integration technique has eliminated many of the rendering artifacts that arise from slicing the volume but it assumes a linear progression of the scalar values between two sample points along the ray. This assumption does not match the quadratic behavior of the scalar values. For this reason, we propose to extend the pre-integration technique for quadratic polynomials. In this section, we present a new model of reconstruction of volume data, namely the quadratic model: we approximate the density function by a piecewise quadratic polynomial. Therefore, we can expand the pre-integration technique, for g(t) being a second degree polynomial, i.e, g(t) = at2 + bt + c. In
CHAPTER 5.3. QUADRATIC CASE
addition, we select the opacity function and the color transfer function being piecewise quadratic.
5.3.2
Strategy
Our goal is to precompute opacity and re ection values for quadratic density model, and store the results into a LUT that can be updated in short time. Unlike the linear case, the volume rendering equation is now depending on one more parameter. This is due to the three coecients present in the density function. Thus, the volume rendering expression depends on four parameters a; b; c and D. This would lead to a four dimensional lookup table, which is computationally expensive and memory consuming. Hence, the idea is to decrease the dimension of the LUT by minimizing the number of involved parameters. We address this problem by performing a variable substitution to reduce the number of parameters, while using the same strategy used for the linear model to deal with the distance length parameter. In the next section, we describe how is that possible. We start by the opacity calculation, then the re ection evaluation for Phong shading.
5.3.3
Opacity Calculation
The opacity function is dened as: = 1 exp(
Z D
0 (g(t))dt): (5.3.1)
In the following, for simplicity, we only develop the case where a > 0. The case where a < 0 can be deduced by simple analogy. Under this assumption, the equation (5.3.1) can be rewritten, by a variable substitution z = t=R, as:
= 1 exp( R Z D0
CHAPTER 5.3. QUADRATIC CASE
where R = 1=pj a j and D0 = D=R. By noting b0 = bR, h(z) is such as: h(z) =
z2+ b0z + c. The dependency of h(z) on R is problematic. Let us discuss the issues to
this problem according to the values of a. First, we choose a threshold " so that: if a < ", the opacity value is obtained by looking up into the 2D LUT opacity generated for the linear case, otherwise, we have to evaluate the equation (5.3.2). Let dene being:
= Z D0
0 (h(z))dz (5.3.3)
Therefore, evaluating (5.3.2) means calculating . Applying directly the variable substitution s = h(z) to the integral leads to wrong results because of the lacking bijectivity of h due to the possible existence of an extremum in h(z). Let denote this extremum if it exists by M = h( b0=2) = c b02=4. Therefore, depending on the
value of b0, we distinguish three possible cases for computing :
8 > > < > > : b0 0; b0 2] 2D0; 0[; b0 2D0. 5.3.3.1 Case I: b0 0
As shown in the gure 5.3, h is monotonous and then a variable substitution s = h(z) can be applied, we obtain therefore:
= Z Sb Sf (s) 2ps Mds = SXb 1 i=Sf Z i+1 i (s) 2ps Mds (5.3.4)
Further, i is dened as:
i =
Z i+1
i
(s)
2ps Mds (5.3.5)
We evaluate the term iby the Simpson rule, since we are considering that the opacity
varies piecewise quadratically inside the sampling interval. Thus, we need three values to approximate the opacity function in this region: (i 0:5); (i) and (i + 0:5).
CHAPTER 5.3. QUADRATIC CASE
Figure 5.3: Variation of h when b0 0
5.3.3.2 Case II: b0 2] 2D0; 0[
For this case, as shown in gure 5.4, has to be divided into two parts: =
Z b0=2
0 (h(z))dz +
Z D0
b0=2(h(z))dz (5.3.6)
The variable substitution s = h(z) leads for the rst subintegral, to z = b0 2ps M
2
and for the second subintegral, to z = b0+2ps M
2 . Now, can be rewritten as:
= Z M Sf (s) 2ps Mds + Z Sb M (s) 2ps Mds = Z Sf M (s) 2ps Mds + Z Sb M (s) 2ps Mds ' SXf 1 i=E(M) i+ SXb 1 i=E(M) i (5.3.7)
CHAPTER 5.3. QUADRATIC CASE
Figure 5.4: Variation of h when b0 2] 2D0; 0[
described for case I.
For the case where M < 0, and since (s) is not dened for s < 0, we solve this problem by setting the negative part of the curve to zero. is then equivalent to:
= SXf 1 i=0 i+ SXb 1 i=0 i (5.3.8) 5.3.3.3 Case III: b0 2D0
As shown in the gure 5.5, h is also monotonous and then a variable substitution s = h(z) can be applied, we obtain therefore:
= Z Sb Sf (s) 2ps Mds = SXb 1 i=Sf Z i+1 i (s) 2ps Mds (5.3.9)
We notice that this equation is no other than the equation 5.3.4 multiplied by 1. For all the cases described above, the value of the opacity is dened such as:
CHAPTER 5.3. QUADRATIC CASE
Figure 5.5: Variation of h when b0 2D0
= 1 exp( R): (5.3.10)
Since depends on the parameters Sf; Sb and M. Or,
M = c b02=4
= Sf + 14(Sb Sf D 02
D0 ) (5.3.11)
Thus, depends on Sf; Sb; D0 and R. Therefore, to store the opacity values, we will
create a 2D LUT depending on D0 and R. For this reason, the D0 and R range have
to be discretized. As described in the last section, for the distance length, we use a logarithmic mapping to cover the range of these both parameters. Sf and Sb are
chosen to be whole numbers, and in case where not, we perform during rendering, a bilinear interpolation between the four nearest neighbors of a non-integer gray value, within the LUTs.
CHAPTER 5.3. QUADRATIC CASE
5.3.4
Re ection Calculation
Under the same notations and by a variable substitution z = t=R, equation (5.1.1) can be rewritten, at t = D, as:
I = R Z D0 0 q(c(h(z)); ~r(h(z))) exp( R Z z 0 (h(z 0))dz0)dz : (5.3.12)
By applying the variable substitution s = h(z) to equation (5.3.12), we obtain the following three cases:
5.3.4.1 Case I: b0 0 I = R Z Sb Sf q(c(s); ~r(s)) 2ps M exp( R Z s Sf (s0) 2ps Mds0)ds: (5.3.13) 5.3.4.2 Case II: b0 2] 2D0; 0[ I = R Z Sf M q(c(s); ~r(s)) 2ps M exp( R Z Sf s (s0) 2ps Mds0)ds +R exp( R Z Sf M (s0) 2ps Mds0)[ Z Sb M q(c(s); r(s)) 2ps M exp( R Z s M (s0) 2ps Mds0)ds]: (5.3.14) 5.3.4.3 Case III: b0 2D0 I = R Z Sb Sf q(c(s); ~r(s)) 2ps M exp(R Z s Sf (s0) 2ps Mds0)ds: (5.3.15) Let us rst consider the ambient re ection part, we replace on equation (5.3.12), q(c(h(z)); ~r(h(z))) by Kac(h(z). We calculate I for each (R; D0) and store it
into a 2D LUT. For the diuse re ection part, we replace on equation (5.3.12), q(c(h(z)); ~r(h(z))) by Kdc(h(z))@@hh(z)( ~N ~L). ~L does not depend on h, thus it
CHAPTER 5.3. QUADRATIC CASE
can be removed out of the integral I. However, the presence of ~N is problematic, since ~N depends on g. We solve this problem by considering ~N being linear over the integration area (g is quadratic). Therefore, 9 ~A; ~B 2 R3 such as:
~
N = ~Az + ~B (5.3.16)
Thus, the diuse re ection part of the ray integral is dened by: Cd =
Z D0
0 Kdc(h(z))
@
@hh(z)(( ~Az + ~B) ~L) exp( R(0; z))dz (5.3.17) It can be rewritten by:
Cd = KdR( ~A ~L) Z D0 0 zc(h(z)) @ @h(h(z)) exp( R(0; z))dz + KdR( ~B ~L) Z D0 0 c(h(z)) @ @h(h(z)) exp( R(0; z))dz: (5.3.18) Therefore, the integral (5.3.18) can be sampled (up to ~A, ~B and ~L), in two 2D LUT. ~A, ~B, and ~L are evaluated, during rendering, in this way:
~A = ( ~rb rf)=D~ 0
~B = ~rf
and ~L the light direction.
where ~rb and ~rf are respectively the gradients at Sb and Sf.
Let us now discuss the case for specular re ection. We replace on equation (5.3.12): q(c(h(z)); r(h)) = Ksc(h(z))(@@hh(z))n( ~N ~H)n
CHAPTER 5.3. QUADRATIC CASE
specular exponent n is problematic. We try to overcome this diculty by applying
the following transform:
( ~N ~H)n = (( ~B + ~Az) ~H)n (5.3.19)
= ( ~B ~H + z ~A: ~H)n
= ( ~B ~H)n(1 + zA ~~ H
~B ~H)n Let us abbreviate ( ~B ~H)n by the scalar u and (A ~~H
~
B: ~H) by the scalar v. Then we have
( ~N ~H)n = u(1 + zv)n and u is now a multiplicative scalar value that can be shifted
out of the rendering integral. Thus, for each sampled value vj of v, we compute the
integral and tabularize it into a 2D LUT. Thus, the specular re ection part of the ray integral can be written as:
Cs = KsRu
Z D0
0 c(h(z))(1 + zRv) n(@
@hh(z))n exp( R(0; z))dz (5.3.20) Therefore, the integral (5.3.20) can be stored (up to ~A; ~B and ~H) into 2D LUT depending on (u; v).
5.3.5
Realization
In this section, we rst show how to generate the opacity LUT, and further the re ection LUT. In the second part, for simplicity, we will consider only the diuse re ection. The ambient and specular LUT can be implemented in a similar way. Here, we consider the gray values vary quadratically between two sample points, a Simpson rule (order 4) for numerical integration of the subintegral within the sampling interval, is by consequence exact.
CHAPTER 5.3. QUADRATIC CASE