IT Uppsala universitet
Data representation and fundamental algorithms
Filip Malmberg [email protected]
UU/IT
08-01-29 | #2@ UU/IT
Data representation Data is discrete, i.e., we only know the data at
a finite set of locations. Interpolation is used to find data values
between sampled points.
UU/IT
08-01-29 | #3@ UU/IT
Data representationData consists of structure (regular or irregular) geometry (Sample locations) attributes (Data at sample locations)
UU/IT
08-01-29 | #4@ UU/IT
Uniform grid• Regular structure• Regular geometry
UU/IT
08-01-29 | #5@ UU/IT
Image data
UU/IT
08-01-29 | #6@ UU/IT
Multi-dimensional images A multi-dimensional image can be considered
as a function f(x,y,z,t,b), where• z: third spatial direction• t: time sequence• b: spectral bands
Different combinations, for example• f(x,y,z,t) is a 4D image representing a time
sequence of volume images
UU/IT
08-01-29 | #7@ UU/IT
Volume images There are several different tomographic
devices:• Computed Tomography (CT)• Magnetic Resonance Imaging (MRI)• Positron Emission Tomography (PET)• and others
UU/IT
08-01-29 | #8@ UU/IT
Computed tomography CT produces anatomical images (attenuation
maps) Low contrast in soft tissue Bone is visible High resolution
UU/IT
08-01-29 | #9@ UU/IT
Magnetic Resonance Imaging MRI produces anatomical images Very good contrast in soft tissue
UU/IT
08-01-29 | #10@ UU/IT
Positron Emission TomographyPET shows the concentration of a positron emitting tracer given to patientFunctional images (show physiological parameters) Low resolution
UU/IT
08-01-29 | #11@ UU/IT
Rectilinear grid• Regular structure• “Partially” regular geometry
UU/IT
08-01-29 | #12@ UU/IT
Structured grid• Regular structure• Irregular geometry
UU/IT
08-01-29 | #13@ UU/IT
Unstructured points• Irregular geometry• No structure
UU/IT
08-01-29 | #14@ UU/IT
Unstructured grid• The most general form of a dataset• A collection of vertices, edges, faces,
any cell type• Connectivity information must be explicitly
stored
UU/IT
08-01-29 | #15@ UU/IT
Example: Polygon mesh
UU/IT
08-01-29 | #16@ UU/IT
How are unstructured meshes different than regular grids?
Regular Gridsmesh info accessed implicitly using grid point indicesefficient in both computation and storagetypically use finite difference (FD) discretizationCartesian grids or logically rectangular grids
UU/IT
08-01-29 | #17@ UU/IT
How are unstructured meshes different than regular grids?
Unstructured Meshes
•mesh connectivity information must be stored•handles complex geometries and grid adaptivity•typically use finite volume or •finite element (FE) discretization•mesh quality becomes a concern
UU/IT
08-01-29 | #18@ UU/IT
Data attributes Scalar Vector
• magnitude and direction Normal
• a vector of magnitude 1• used for lighting
Texture coordinate• mapping data points into a texture space
Tensor
UU/IT
08-01-29 | #19@ UU/IT
Operations on datasets• Geometric transformations• Topological transformations• Attribute transformations• Combined transformations
UU/IT
08-01-29 | #20@ UU/IT
Scalar algorithms: Color mapping Colour mapping is a common scalar
visualization technique that maps scalar data to colours
The scalar values serve as indices into a colour lookup table
Or mapping through a transfer function
UU/IT
08-01-29 | #21@ UU/IT
Colour mapping
UU/IT
08-01-29 | #22@ UU/IT
Scalar algorithms: Isocontour/Isosurface Extractions
2D isocontours 3D isosurface
UU/IT
08-01-29 | #23@ UU/IT
Surface rendering of volume dataThe data must be converted to an intermediate surface description using geometric primitives
UU/IT
08-01-29 | #24@ UU/IT
Surface versus Volume rendering Surface Rendering We assume that data to
be visualized can be modelled by surfaces. Normally, we model the object with geometric primitives such as points, lines, triangles or polygons and use standard Computer Graphics techniques to render the data
Volume Rendering operates on the data itself and takes into account the changing properties inside the object
UU/IT
08-01-29 | #25@ UU/IT
Surface reconstruction from volumesThe by far most popular method is the Marching Cubes algorithm (MC) (Lorensen et al., SIGGRAPH 1987)MC uses the grey-scale information in the data to build triangulated surfacesMC works by looking at each element of the volume dataset one at a time to decide whether its vertices are inside or outside the isosurfaceThis decision is made by comparing the values at the vertices of the volume elements with the value which has been defined as the surface valueIf the surface passes through the volume element, the approximate position of the isosurface intersection is calculated, normally using trilinear interpolation
UU/IT
08-01-29 | #26@ UU/IT
Isocontour vs interpolation
Remember bi-linear interpolation?
p2 p3
p0 p1
P = ?
p4 p5
To know the value of P, we can first compute p4 and p5 and then linearly interpolate P
The problem of extracting an isocontour is the inverse of value interpolation
UU/IT
08-01-29 | #27@ UU/IT
Isocontour, cont’d
p2 p3
p0 p1
(2) Calculate the positions of P
(3) Connect the points with lines
We can solve the problem based on linear interpolation
(1) Identify edges that contain points P with value C, i.e., if pi < C < pj
UU/IT
08-01-29 | #28@ UU/IT
In how many ways can a contour intersect a 2D cell?
Two contours pass through the cell
In fact, there are only 4 unique topological cases
Contour completely outside cell
One vertex inside, three vertices outside (or vice versa)
Two vertices inside, two vertices outside
UU/IT
08-01-29 | #29@ UU/IT
Marching Squares
4 pixels in a 2 x 2 neighbourhood
8 of 16 possible configurations
UU/IT
08-01-29 | #30@ UU/IT
Divide-and-conquer Algorithm
• Look at one cell at a time
• Compare the values at 4 vertices with the isovalue C
• Linearly interpolate along the edges
• Connect the interpolated points together
UU/IT
08-01-29 | #31@ UU/IT
Boundary representations
Pixel edgesMarching squares
UU/IT
08-01-29 | #32@ UU/IT
Marching Cubes
A marching cube is bounded by the 8 voxels in a 2 x 2 x 2 neighbourhood
If object (value=1) and background (value=0) are considered, then there are 28 = 256 possible configurations of the 8 voxels
UU/IT
08-01-29 | #33@ UU/IT
Conversion of voxel data to triangulated surfaces
UU/IT
08-01-29 | #34@ UU/IT
MC algorithm
Step 1 – Create the cubes using the centres of 8 voxels; four from slice k four from slice k+1
1
3
2
4
5
7
6
8
UU/IT
08-01-29 | #35@ UU/IT
MC algorithm
Step 2 - Classify each vertex of the cube
1 = inside the object
0 = outside the object
Step 3 - Build an index
The classification gives an 8-bit index number (e.g., 01100111, 00110010) for each cube
UU/IT
08-01-29 | #36@ UU/IT
Cube example
Marching cube configuration 001100102 = 50, Case 5, 3 triangles
UU/IT
08-01-29 | #37@ UU/IT
MC algorithm
Step 4 –
Get the edge list
For a given index, access a list of cube edges (a lookup table) that contains triangle vertices
1
3
245
7
68
1211
109
UU/IT
08-01-29 | #38@ UU/IT
MC algorithm
Step 5 - Interpolate the triangle verticesFor the cube edges, find the intersection points using (linear) interpolation of the density values
The midpoint of the cube edge may be chosen for the triangle vertex
UU/IT
08-01-29 | #39@ UU/IT
MC algorithm, final step
Step 6 - Calculate a unit normal for each triangle vertex Estimate a gradient vector G at each cube vertex using central differences of the density data D
Gx(i,j,k) = D(i+1, j, k) - D(i-1, j, k)Gy(i,j,k) = D(i, j+1, k) - D(i, j-1, k)Gz(i,j,k) = D(i, j, k+1) - D(i, j, k-1)
Interpolate the gradient at the intersection, i.e., the triangle vertex
Rendering algorithms use the normals to produce, e.g., Gouraud shading
UU/IT
08-01-29 | #40@ UU/IT
Marching Cubes -Algorithm in summary
1. Create a cube2. Classify each vertex3. Build an index4. Get edge list5. Interpolate triangle vertices6. Calculate and interpolate normals
UU/IT
08-01-29 | #41@ UU/IT
More cube examples
Case 1 Case 2 Case 8
UU/IT
08-01-29 | #42@ UU/IT
Non-boundary cubes
Completely outside object Completely inside object
UU/IT
08-01-29 | #43@ UU/IT
Tricky configurations
Case 6
5 triangles
UU/IT
08-01-29 | #44@ UU/IT
MC – Pros and cons
?
•Straightforward to implement•Fast to generate•Generates many, many triangles •Does not always connect things in a correct way (ambiguities)
•The generated surfaces are not perfectly smooth
UU/IT
08-01-29 | #45@ UU/IT
MC – Pros and cons
UU/IT
08-01-29 | #46@ UU/IT
Voxel examples: sphere and cube
UU/IT
08-01-29 | #47@ UU/IT
MC examples: sphere and cube
UU/IT
08-01-29 | #48@ UU/IT
Vector algorithms
Vector data is a 3D representation of direction and magnitudeLike scalar fields, vectors are defined at discrete points
UU/IT
08-01-29 | #49@ UU/IT
Vector field visualization challenges
Displaying a vector requires more visual attributes
(u,v,w) has direction and magnitude
Displaying a vector requires more screen space
more than one pixel is required to display an arrow
It becomes more challenging to display a dense vector field
UU/IT
08-01-29 | #50@ UU/IT
Glyphs
•A general visualization technique used to represent data using a meaningful shape or pictorial representation
•Each glyph is generally a function of its input data and may change size, orientation, colour, and shape
•Example: oriented arrows, cones, etc.
UU/IT
08-01-29 | #51@ UU/IT
Animated particles
Advection of (massless) particles through the vector field
UU/IT
08-01-29 | #52@ UU/IT
Streamlines
•Curves that connect particle positions
•Start from one or more seed-points
IT Uppsala universitet
Data representation and fundamental algorithms
Filip Malmberg [email protected]
Top Related