+ All Categories
Home > Documents > Yingcai Xiao

Yingcai Xiao

Date post: 15-Mar-2016
Category:
Upload: liluye
View: 47 times
Download: 0 times
Share this document with a friend
Description:
Chapter 6 Fundamental Algorithms. Yingcai Xiao. Types of Visualization. Transformation Types Data (Attribute Transformation) Topology (Topological Transformation) Geometry(Geometric Transformation) Combined Visualization Algorithm Types Scalar Algorithms Vector Algorithms - PowerPoint PPT Presentation
53
Yingcai Xiao Chapter 6 Fundamental Algorithms
Transcript
Page 1: Yingcai Xiao

Yingcai Xiao

Chapter 6

Fundamental Algorithms

Page 2: Yingcai Xiao

Types of VisualizationTypes of Visualization Transformation Types1.Data (Attribute Transformation)2.Topology (Topological Transformation)3.Geometry(Geometric Transformation)4.Combined  Visualization Algorithm Types1.Scalar Algorithms2.Vector Algorithms3.Tensor Algorithms4.Modeling Algorithms

Page 3: Yingcai Xiao

Color Mapping

Page 4: Yingcai Xiao

Scalar Algorithms: Color Mapping

• Color mapping is a common scalar visualization technique that maps scalar data to colors.

• The scalar mapping is implemented by indexing into a color lookup table (discrete).

Page 5: Yingcai Xiao

Scalar Algorithms: Color Mapping

Page 6: Yingcai Xiao

Scalar Algorithms: Color Mapping

V < min => i = 0 V > max => i = n-1i = (n-1) * (V - min) / (max – min) max lower bound (mlb)i = (truncate) (n-1) * (V - min) / (max – min) least upper bound (lub)i = (ceiling) (n-1) * (V - min) / (max – min)  

Page 7: Yingcai Xiao

A Color Table

Page 8: Yingcai Xiao

Scalar Algorithms: Color Mapping

• To define a color table we need to provide the number of colors and the color for each entry.

• To use a color table we need to provide the range of the scalar values.

• One color table can be used by multiple scalars.  

Page 9: Yingcai Xiao

A Color Map

Page 10: Yingcai Xiao

Scalar Algorithms: Color Mapping

• A color table is discrete.• A transfer function is continuous.• A transfer function can be any

monotonic expression that maps scalar value into a color specification (continuous).R = Fr(V); G = Fg(V); B = Fb(V);

Page 11: Yingcai Xiao

Programming

Page 12: Yingcai Xiao

Color Map Programming: Creating a Color TablevtkLookupTable *lut = vtkLookupTable:New(); lut->SetHueRange(0.667, 0); //value range [0, 2* П] lut->SetSaturationRange(1,1); lut->SetValueRange(1,1); lut->SetAlphaRange(1,1); // transparency lut->SetNumberOfColor(256); lut->Build();

 

Page 13: Yingcai Xiao

Color Map Programming: Creating a Color Table

• Linear interpolation to build the tablec: h, s, v, a;  • Modify the color of an entry (i) in the LUT lut->SetTableValue(i, h, s, v, a);  

 

Page 14: Yingcai Xiao

Color Map Programming: Using a Color Table• mapperSetLookupTable(lut)• There is a default red—blue color table.• Mapper maps scalars to colors according to lut (Linear interpolation b/w entries)• For the default lut, it uses data range set by mapperSetScalarRange(d0, d1)• To turn the scalar-color mapping off: MapperScalarVisibilityOff();

 

Page 15: Yingcai Xiao

Color Map Programming: Using a Color Table• To force VTK to use a single object color: ActorGetProperty()SetColor(R,G,B)• SubClassing from vtkLookUp Table• VtkLogLookUpTable uses log scale instead linear interpolation.

 

Page 16: Yingcai Xiao

Contouring

Page 17: Yingcai Xiao

Scalar Algorithms: Contouring

A contour is a line (2D) or a surface (3D) of constant data values.

 

Page 18: Yingcai Xiao

ElevationContours

Page 19: Yingcai Xiao

Scalar Algorithms: Contouring

Page 20: Yingcai Xiao

Contouring: Edge Tracking (2D)

Tracks a contour as it moves across cell boundaries.1.For each unprocessed cell, check if the contour passes through one of its edges by checking if the contour value is between the nodal data values. 2.If not, mark the cell processed and go to the next unprocessed cell.3.If an edge intersection detected, follow the contour to the exit edge and track the contour to the next cell until the contour closes itself or exit from a boundary edge. Mark each cell processed as the contour passes it.4.Start the next unprocessed cell till all cells are processed.

Page 21: Yingcai Xiao

Contouring: Marching Squares (2D)

Processing each cell independently, using state code to determine how to draw the contour line.

1. Loop through every cell. For each cell,2. Encoding the state of each vertex as binary code (state code):

inside (data value > contour value) or outside (data value < contour value).

Page 22: Yingcai Xiao

Contouring: Marching Squares (2D)

3. Create an index based on the bitwise combined state codes of the vertexes. (Similar to the outcode in Cohen-Sutherland clipping)

4. Using the index to look up the topological state of the cell in a case table. (how)

5. Calculate the contour location (geometry) for each edge in the case table. (where)

Page 23: Yingcai Xiao

Marching Squares: Case Table

Page 24: Yingcai Xiao

Contouring: Marching Squares (2D)

• 16 cases (4 bit indexing)• 6 unique topological cases (one unique case for n vertex inside, n

= 0, 1, 2, 3, 4. One additional case for 2 inside vertexes: diagonal (vs. same side).

• From programming point of view, there are only 4 unique cases: no draw (n=0 or 4); cut one corner (n=1 or 3); cut one side (two connected corners); and cut two opposite corners.

Page 25: Yingcai Xiao

Contouring Ambiguity

• Need to see how its neighbors are drawn to decide which way to draw.

• Or to use gradient information to decide which way to draw.

Page 26: Yingcai Xiao

Marching Cubes

Page 27: Yingcai Xiao

Marching Cubes (3D)

• Similar to 2D Marching Squares. • Larger case table: 8 vertices, 256 cases.• 15 unique cases.

Page 28: Yingcai Xiao

Marching Cubes

Page 29: Yingcai Xiao

Scalar Generation

Page 30: Yingcai Xiao

Scalar Generation• Converting complex input into a scalar (single valued) to use scalar algorithms.

 e.g.: the length of a vector field.

• Each data field has one data value. valuecolorvaluecontour

 

Page 31: Yingcai Xiao

Programming

Page 32: Yingcai Xiao

Contour (Isosurface) Programming// Create an implicit function (continuous)vtkQuadric *q = vtkQuadric::New(); qSetCoefficients=(5,1,2,0,1,0,0,2,0,0);// F(x,y,z) = 5x2 + y2 + 2z2 + yz + 2yF(x,y,z) = a0*x^2 + a1*y^2 + a2*z^2 + a3*x*y + a4*y*z + a5*x*z + a6*x + a7*y + a8*z + a9//Create a sample filter (discrete)vtkSampleFunction *s = vtkSampleFunction::New(); sSetImplicitFunction(q); sSetSampleDimensions(50,50,50); // uniform grid 

 

Page 33: Yingcai Xiao

Contour (Isosurface) Programming//Create a contour filter objectvtkContourFilter *c= vtkContourFilter::New(); cSetInput(sGetOutput()); //Create contours cGenerateValues(4,0,3)//first: number of contours//second: starting value //third: ending value 

Page 34: Yingcai Xiao

Contour Programming//Create a mapper to hold the geometry of the contoursvtkPolyDataMapper *m= vtkPolyDataMapper::New();mSetInput(cGetOutput);mSetScalarRange(0,3); // for color mapping //Create an actor to hold the geometryvtkActor *a= vtkActor::New();aSetMapper(m);

 

Page 35: Yingcai Xiao

Contour (Isosurface) Programming

Page 36: Yingcai Xiao

Vector Algorithms

Vector data is a three-dimensional representation of direction and magnitude.

3 values: (vx, vy, vz) => direction and length

Page 37: Yingcai Xiao

Vector Algorithms: Vector Algorithms: Directed LinesDirected LinesDraw a directed line based on the vector value at each data point. A scaling factor is needed to map the data vector field to the display vector field so that the displayed vectors will not be too small or too large.

        

Page 38: Yingcai Xiao

Vector Algorithms: Vector Algorithms: HedgehogsSimilar to Directed Lines, but no direction arrow on the lines.

        

Page 39: Yingcai Xiao

Vector Algorithms: Vector Algorithms: Oriented GlyphsSimilar to Directed Lines, but use graphical objects to represent vector values.

        

Page 40: Yingcai Xiao

Vector Algorithms: Vector Algorithms: Warping Deformation of geometry according to a vector field.         

Where DX is the deformation, V is the vector field and α is the scaling factor.

Page 41: Yingcai Xiao

Vector Algorithms: Vector Algorithms: Displacement Plots Shows the motion of an object in the direction perpendicular to its surface.          Vectors are converted to scalars by

computing the dot product between the surface normal (N) and vector (V) at each point.

Where D is the displacement, V is the vector field, N is the normal field and α is the scaling factor.

Page 42: Yingcai Xiao

Vector Algorithms: Vector Algorithms: Time Animation Time dependent geometry change according to a vector field.

       

Where dX is the geometry change, V is the vector field, α is the scaling factor and dt the time elapsed from previous step. Most vector algorithms need to use a scaling factor to map the data vector field to the display so that the displayed results will not be too small or too large.

Page 43: Yingcai Xiao

Vector Algorithms: Vector Algorithms: Streamlines

Page 44: Yingcai Xiao

Vector Algorithms: Vector Algorithms: StreamlinesParticle Traces: trajectories traced by fluid particles over time. Each trajectory follows a particle.Streaklines: the set of particle traces at a particular time that have previously passed through a specific point. Streamlines: a snap shot of how particles will move at different locations at a given time. The tangent of the streamline curve at any given location represents the vector value at the location.

      

where s is the path on a streamline, V is the vector field.

Page 45: Yingcai Xiao

Vector Algorithms: Vector Algorithms: Streamlines

When the vector field is time independent, all three methods can generate the same result.

Page 46: Yingcai Xiao

Tensor AlgorithmsTensor Algorithms

9 data values at each point

Page 47: Yingcai Xiao

Tensor AlgorithmsTensor Algorithms

Convert a tensor into three vectors (X)AX = Xdet |A-I| = 0Using three eigenvalues and three eigenvectors:1 2 3

X1 X2 X3

Tensor ellipsoid: an ellipsoid drawn using the three eigenvectors as the major, medium, minor axis.

Page 48: Yingcai Xiao

Tensor AlgorithmsTensor Algorithms

Page 49: Yingcai Xiao

Modeling AlgorithmsModeling Algorithms

For creating or changing dataset geometry or topology.

Page 50: Yingcai Xiao

Modeling AlgorithmsModeling Algorithms

Source Objects: used to define geometry, read data from data file, create data. Implicit Functions:F(x, y, z) = C: Generate geometry.Region separation, F>4, F=4, F<4. 

Page 51: Yingcai Xiao

Modeling AlgorithmsModeling Algorithms

Modeling ObjectsF(x,y,z) = x*x + y*y + z*z

=> Creates a data set with field value F(xi,yj,zk);F(x,y,z) = 1.0;

=> Creates an Isosurface (a sphere object). Logical operations on two fields: F and GFG = min(F, G)FG = max(F,G)F - G = max(F-G) 

Page 52: Yingcai Xiao

Modeling AlgorithmsModeling Algorithms

Implicit Modeling Scalars are generated using a distance function to a given object. Cutting: Cutting through a data set with a surface and then display the interpolated data values on the surface.•Geometric intersections•Interpolate data values onto the surface.•Map the data into color or contours. 

Page 53: Yingcai Xiao

Modeling AlgorithmsModeling Algorithms

Cutting: Cutting through a data set with a surface and then display the interpolated data values on the surface.


Recommended