.
Fractal Image Compression 29.january.1998 GFX

by Hin Jang

A fractal is an image that consists of local self-similarities; regions that look like other parts. A region of the original image is denoted by the domain Di and copies of that part is denoted by the range Ri. The boundaries of these pieces are the result of either adaptive quadtree partitioning or triangular partitioning. Each domain is subject to an affine tranformation wi to yield its corresponding range. The transformations are of the form

      | x |     | ai  bi  0 | | x |     | ei |
   wi | y |  =  | ci  di  0 | | y |  +  | fi |
      | z |     | 0   0  si | | z |     | oi |

The grey level of a pixel is z at position (x, y). The values of ai bi, ci, di, ei and fi define the position and scaling, stretching, skewing and rotation factors for each copy. The values of si and oi determine the contrast and brightness of the transformation. The set of transformations are contractive in that for any two points P0 and P1 the distance
   d(w(P0), w(P1))  <  sd(P0, P1)

for some s less than one. These contractive transformations define an partitioned iterated function system (PIFS) that maps a plane onto itself. Given an input image f, the union of w1(f), w2(f), ... ,wn(f), yields a new set W(f). That is
   f  =  W(f)  =  w1(f)  U  w2(f)  U  ...  wn(f)

Fractal image compression is achieved by finding the domains Di and maps wi so when the algorithm applies wi to the part of the image over Di the result is close to the part of the image over Ri [1].

Suppose f is a 512 × 512 pixel image with each pixel having one of 256 levels of grey. Assuming a naive implementation of quadtree partitioning, let the ranges R1, R2, ..., R1024 be 16 × 16 pixel non-overlapping sub-squares of f. Futhermore, let D be the set of all 32 × 32 pixel overlapping sub-squares of f. The range Ri is found my searching through the set D to find a Di to minimise the quantity

     n
   ----
   \      (s . ai  +  o - bi)2
   /
   ----
   i=1

where there are n pixels from Di with intensities a1, ..., an and n pixels from Ri with intensities b1, ..., bn. The minimum of this quantity occurs for s and o where
             n               n          n
            ----            ----       ----
        n   \     ai bi  -   \    ai    \     bi
            /               /          /
            ----            ----       ----
            i=1             i=1        i=1
   s  =  --------------------------------------
                                            2
                 n           |    n     |  
                ----         |   ----   |
             n  \    ai2  -   |   \   ai |
                /            |   /      |
                ----         |   ----   |
                i=1          |   i=1    |

[1, 7] and
            n                n
           ----             ----
           \     bi  -   s  \     ai
           /                /
           ----             ----
           i=1              i=1
   o  =  -----------------------  
                    n

[1]. If the denominator in the first equation is zero then s = 0 and o becomes
    n
   ----
   \     bi / n
   /
   ----
   i=1

The choice of Di and the corresponding values of si and oi determines a map wi [1]. The image can then be decoded once the values of w1, ..., w1024 are found.

The site ftp://ftp.Informatik.Uni-Freiburg.DE/documents/papers/fractal/ contains papers, software and an updated bibliography related to fractal image compression.



[1] Fisher, Y., "Fractal Image Compression: SIGGRAPH 1992 Course Notes," Computer Graphics, SIGGRAPH 1992 Proceedings, 26(4)

[2] Hamzaoui, R., Fast Decoding Algorithms for Fractal Image Compression, Institut für Informatik - Report 86, Universität Freiburg, Germany, March 18, 1997

[3] Krupnik, H., D. Malah, and E. Karnin, Fractal Representation of Image via the Discrete Wavelet Transform, Department of Electrical Engineering, Technion - Israel Institute of Technology, 1995

[4] Levy, I., and R. Wilson, A Hybrid Fractal-Wavelet Transform Image Data Compression Algorithm, Department of Computer Science, University of Warwick, Coventry, UK, September 1, 1995

[5] Saupe, D., Lean Domain Pools for Fractal Image Compression, Institut für Informatik - Report 73, Universität Freiburg, Germany, 1995

[6] Saupe, D., Fractal Image Compression via Nearest Neighbor Search, Institut für Informatik - Report 74, Universität Freiburg, Germany, January 8, 1996

[7] Saupe, D., R. Hamzaoui, and H. Hartenstein, Fractal Image Compression - An Introductory Overview, Institut für Informatik, Universität Freiburg, Germany, 1996


.
Potential Visible Sets 06.april.1998 GFX

by Hin Jang

Architectural models may consist of several million polygons. A traversal through the model requires an efficient algorithm to determine which polygons are visible to the observer. Hierarchical schemes partition the environment to allow efficient reduction of the superset of polygons down to a more managable subset of candidate polygons. Teller et al developed an efficient and effective visibility algorithm most appropriate for axis-aligned surfaces [6, 7, 8]. The method subdivides the model into rectangular cells whose boundaries are coincident to opaque surfaces (i.e, walls). Non-opaque portions of shared boundaries between rooms, such as doorways, are called portals. Once the cells and portals are identified, an adjaceny graph is constructed. The graph vertices are the cells and the graph edges represent a portal that connects a pair of cells. For each cell in the subdivision, cell-to-cell visibility is computed by linking pairs of cells where there exists an unobstructed sightline. Following these sightlines from one cell to the next results in a portal sequence from which a stab tree for each leaf node of the subdivision is generated. During traversal through the model, the cell in which the observer resides is identified. The stab tree for that cell is then retrieved from memory whereupon its members are culled against the observer's view frustum to give a potential visibile set (PVS). Front-facing and non-occluded surfaces of the PVS are then rendered.

A kD tree represents the spatial subdivision. Each node of the tree is associated with a cell bounded by k half-open extents [x0, min ... x0, max), ..., [xk-1, min ... xk-1, max). The extents are also defined accordingly along the y and z axes. A node that is not a leaf has a split dimension s, where 0 <= s < k; a split abscissa a such that xs, min < a < xs, max; and two child nodes. The extents of the left node are the same as its parent except for k = s, in which case the extents are [x0, min ... a). For the right node, the extexts are [a ... x0, min). The kD tree is initialised to the bounding box surrounding the entire model. Each surface F is classified with respect to the root cell

Each spanning, covering and incident surface is stored in the appropriate child node. If there is more than one possible spanning surface, the one chosen as the median abscissa partitions best the cell in two equal volumes. Given the root cell and now two leaf cells, each child is subject to recursive subdivision that continues until there are no incident surfaces in a given cell. When the entire model is subdivided as such, the portals are enumerated and stored with each leaf cell, along with an identifier to the neighbouring cell to which the portal connects [8].

The cell-to-cell visibility information about each leaf cell yields a portal sequence. By following the sightlines that stab a portal to reach the next cell, such a sequence is formed. For the given layout

   +---------------------+
   |                     |
   |          A          |
   |                     |
   +---     --+--     ---+
   |          |          |
   |          |          |
   |    B          C     |
   |                     |
   |          |          |
   +---     --+--     ---+
   |                     |
   |          D          |
   |                     |
   +---------------------+
   
and that P/Q denotes a portal from cell P to cell Q, the four portal sequences originating from cell A are
   [A/B, B/C, C/D]
   [A/C, C/B, B/D]
   [A/B, B/D]
   [A/C, C/D]

To find the visible cells from an arbitrary cell requires a recursive depth-first traveral of its neighbours. Cells reached by this traversal are stored in a stab tree. A sightline is said to stab a portal sequence P if and only if there exists a line S such that
   S . L >= 0,      for all L in L
   S . R <= 0,      for all R in R

where the orientation of each portal is identified by its left (L) and right (R) endpoints. The pseudocode to find all cells visible from any cell C is

   Find_Visible_Cells(Cell C, PSequence P, VisibleSet V)
   {
      V = Add(V, C)
      for (each neighbour N of C) {
         for (each portal p connecting C and N) {
            orient p from C to N
            P' = Add(P, p)
            if (Stabbing_Line_Exists(P'))
               Find_Visible_Cells(N, P', V)
         }
      }
   }

For the following spatial subdivision
   +-------------+----------------------------+
   |             |                            |
   |                                          |
   |      I                       J           |
   |                                          |
   |             |                            |
   +-----      --+---+-       --------        |
   |      F          |                        |
   |                 |            H           |
   |   +----+        |                        |
   |   |    |        |                        |
   | B |  D |   E    +-       ----------------+
   |   +----+        |                        |
   |                 |                        |
   |      C          |                        |
   |   --------------+                        |
   |                 |                        |
   |                 |                        |
   |      A                       G           |
   |                                          |
   +------------------------------------------+

the visiblity V returned from Find_Visible_Cells( ) with I as the source cell (i.e., where the observer resides) is
   { I, F, B, E, C, J, H }

[8] and the associated stab tree for I is
                 I
                 |
          +-------------+
          |             |
     I/F  |             |  I/H
          |             |
          F             J
          |             |
     +--------+    +---------+
     |        |    |         |
F/B  |    F/E |    | J/H1    |  J/H2
     |        |    |         |
     B        E    H         H
              |
         +----
         |
     E/C |
         |
         C

[8]. Each leaf node of the kD tree has a stab tree from which cell-to-cell visibility is the set of stab tree vertices.



[1] Aliaga, D.G., and A.A. Lastra, Visibility Culling Using Portal Textures, TR-97-009, Department of Computer Science, University of North Carolina, Chapel Hill, April 1997

[2] Chamberlain, B., T. DeRose, D. Lischinski, D. Salesin, and J. Snyder, "Fast Rendering of Complex Environments Using a Spatial Hierarchy," Graphics Interface 1996

[3] Coorg, S., and S. Teller, A Spatially and Temporally Coherent Object Space Visibility Algorithm, Technical Report TM-546, Synthetic Imagery Group, MIT Laboratory for Computer Science, Cambridge, Massachusettes, February 1996

[4] Coorg, S., and S. Teller, "Realtime Occlusion Culling for Models with Large Occluders," 1997 Proceedings of the ACM Symposium on Interactive 3D Graphics, 83-90

[5] Shade, J., D. Lischinski, D.H. Salesin, T. DeRose, and J. Snyder, Hierarchical Image Caching for Accelerated Walkthroughs of Complex Environments, Technical Report UW-CSE-96-01-06, Department of Computer Science and Engineering, University of Washington, January 1996

[6] Teller, S.J., Visibility Computations in Densely Occluded Polyhedral Environments, UCB/CSD-92-708, Ph.D. dissertation, Computer Science Division (EECS), University of California, Berkeley, October 1992

[7] Teller, S.J., and M.E., Hohmeyer, Stabbing Oriented Convex Polygons in Randomised O(n2) Time, Computer Science Department, University of California at Berkeley, 1992

[8] Teller, S.J., and C.H. Séquin, "Visibility Preprocessing For Interactive Walkthroughs," Computer Graphics, SIGGRAPH 1991 Proceedings, 25(4):61-68

[9] Zhang, H., D. Manocha, T. Hudson, and K. Hoff, Visibility Culling Using Hierarchical Occlusion Maps, TR-97-004, Department of Computer Science, University of North Carolina, Chapel Hill, February 21, 1997


.
Surface Detail Augmentation 01.march.1998 GFX

by Hin Jang

Displacement Mapping
The use of displacement mapping can augment the visual features of an object without having to complicate its underlying mathematical model. Bumps and depressions are simulated by applying such mappings in directions normal to a surface. Displacements may also occur along linear and curved trajectories, some of which operate in directions non-orthogonal to a surface [5].

Given a point X on a parameterised surface, the explicit expression for the displaced point X' is

   X'(u, v)  =  X(u, v)  +  n(u, v) g(u, v)

where n(u, v) is the local surface normal and g(u, v) is the displacement map function. If the values of g(u, v) correspond to Gaussian weighted averages, a positively displaced surface, once rendered, would appear to have smooth bumps. Displacements along flow fields give rise to more visually complex surfaces. For a three-dimensional flow § defined as
   §(u, v, t0)  =  X(u, v)

   §(u*, v*, t)  =  X(u*, v*)

            d§
   v(t)  =  -- (u, v, t)  >  0
            dt

the explicit expression for a displaced point X' along a linear portion of §, with velocity vector v(t), is
                              v(t)
   X'(u, v)  =  X(u, v)  +  --------  g(u, v)
                            | v(t) |

The signed values of g(u, v) are linear distances measured in R³. The arc length between a point X and its projection X' along a curved trajectory is
           t0
          |\
          |      d§
   d§  =  |      -- (§-1(u, v) , s)  ds
          |      dt
         \|
           §-1(t)

There exist optimsations for the calculation of the integral so that non-linear arc-length displacements are a feasible method for surface editing at interactive rates [5].

Bump Mapping
The premise of bump mapping is to shade a surface as though it had tiny bumps. While the surface geometry does not change, the surface normal at many points is perturbed slightly [2]. An illumination model uses these vectors to simulate the effect of light reflecting from tiny perturbations across the surface. Bump mapping differs from displacement mapping in that the latter technique is a direct approach to rendering surface detail, whereas the former technique simply modifies a parameter to an illumination equation.

At some point P, a height field f(u,v) perturbs the surface along its normal vector N = (Pu × Pv) / |(Pu × Pv)|. Given partial derivatives of the height field in u and v, the perturbed normal vector N' is

           (Pu × Pv)  +  D
   N'  =  -------------------
          | (Pu × Pv)  +  D |

where
   D  =  - fu (Pv × N)  -  fv (N × Pu)

The evaluation of N' for every point is impractical to achieve interactive framerates. An optimisation method is therefore necessary. Let the local space in which the perturbation occur be defined by the normal vector N = (0, 0, 1), the tangent vector T = Pu / |Pu| = (1, 0, 0) and the binormal B = N × T = (0, 1, 0). for the parametric direction in v
   Pv  =  (T . Pv)T  +  (B . Pv)B

and
   Pv × N  =  (B . Pv)T  -  (T . Pv)B

Substitution into D yields
   D  =  -fu(Pv × N)  -  fv(N × Pu)
      =  -fu(Pv × N)  -  fv|Pu|B
      =  -fu[(B . Pv)T  -  (T . Pv)B]  -  fv|Pu|B
      =  -fu(B . Pv)T  -  (fv|Pu|  -  fu(T . Pv))B
    
[4]. Assuming Pu and Pv are orthogonal and each are equal in magnitude, which implies
   Pu . Pv  =  T . Pv  =  0

and
   |Pu|  =  |Pv|  =  k

then
   D  =  -fukT  -  fvkB

And finally, Pu × Pv = |Pu × Pv|N, so the perturbed normal is
            k2N  +  D
   N'  =  ------------
          | k2N  +  D |

            k2N -  fukT  -  fvkB
       =  ------------------------
          | k2N -  fukT  -  fvkB |

                 (-fuk, -fvk, k2)
       =  --------------------------------
          [(-fuk)2  +  (-fvk)2  +  k4] 0.5

Values of N' are precomputed and can be applied to any surface. The constant k is the relative height of the bumps.



[1] Barghiel, C., R. Bartels, and D. Forsey, Pasting Spline Surfaces, TR-95-32, Department of Computer Science, University of British Columbia, 1995

[2] Becker, B.G., and N.L. Max, "Smooth Transitions between Bump Rendering Algorithms," Computer Graphics, SIGGRAPH 1993 Proceedings, 27(4):183-190

[3] Max, N.L., and B.G. Becker, "Bump Shading for Volume Textures," IEEE Computer Graphics and Applications, 14(4):18-20, July 1994

[4] Percy, M., J. Airey, and B. Cabral, "Efficient Bump Mapping Hardware," Computer Graphics, SIGGRAPH 1997 Proceedings, 31(4):303-306

[5] Perdersen, H.K., "Displacement Mapping Using Flow Fields," Computer Graphics, SIGGRAPH 1994 Proceedings, 28(4):279-286