Download presentation

Presentation is loading. Please wait.

Published byAnnabel Channon Modified about 1 year ago

1
Yingcai Xiao Chapter 6 Fundamental Algorithms

2
Types of Visualization Transformation Types 1.Data (Attribute Transformation) 2.Topology (Topological Transformation) 3.Geometry(Geometric Transformation) 4.Combined Visualization Algorithm Types 1.Scalar Algorithms 2.Vector Algorithms 3.Tensor Algorithms 4.Modeling Algorithms

3
Color Mapping

4
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).

5
Scalar Algorithms: Color Mapping

6
V i = 0 V > max => i = n-1 i = (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)

7
A Color Table

8
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.

9
A Color Map

10
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);

11
Contouring

12
Scalar Algorithms: Contouring A contour is a line (2D) or a surface (3D) of constant data values.

13
Scalar Algorithms: Contouring

14
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.

15
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).

16
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)

17
Marching Squares: Case Table

18
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.

19
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.

20
Marching Cubes

21
Marching Cubes (3D) Similar to 2D Marching Squares. Larger case table: 8 vertices, 256 cases. 15 unique cases.

22
Marching Cubes

23
Scalar Generation

24
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. value color value contour

25
Programming

26
Color Map Programming: Creating a Color Table vtkLookupTable *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();

27
Color Map Programming: Creating a Color Table Linear interpolation to build the table c: h, s, v, a; Modify the color of an entry (i) in the LUT lut->SetTableValue(i, h, s, v, a);

28
Color Map Programming: Using a Color Table mapper SetLookupTable(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 mapper SetScalarRange(d 0, d 1 ) To turn the scalar-color mapping off: Mapper ScalarVisibilityOff();

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

30
Contour (Isosurface) Programming // Create an implicit function (continuous) vtkQuadric *q = vtkQuadric::New(); q SetCoefficients=(5,1,2,0,1,0,0,2,0,0); // F(x,y,z) = 5x 2 + y 2 + 2z 2 + yz + 2y F(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(); s SetImplicitFunction(q); s SetSampleDimensions(50,50,50); // uniform grid

31
Contour (Isosurface) Programming //Create a contour filter object vtkContourFilter *c= vtkContourFilter::New(); c SetInput(s GetOutput()); //Create contours c GenerateValues(4,0,3) //first: number of contours //second: starting value //third: ending value

32
Contour Programming //Create a mapper to hold the geometry of the contours vtkPolyDataMapper *m= vtkPolyDataMapper::New(); m SetInput(c GetOutput); m SetScalarRange(0,3); // for color mapping //Create an actor to hold the geometry vtkActor *a= vtkActor::New(); a SetMapper(m);

33
Contour (Isosurface) Programming

34
Vector Algorithms Vector data is a three-dimensional representation of direction and magnitude. 3 values: (v x, v y, v z ) => direction and length

35
Vector Algorithms: Directed Lines Draw 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.

36
Vector Algorithms: Vector Algorithms: Hedgehogs Similar to Directed Lines, but no direction arrow on the lines.

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

38
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.

39
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.

40
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.

41
Vector Algorithms: Vector Algorithms: Streamlines

42
Particle 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.

43
Vector Algorithms: Vector Algorithms: Streamlines When the vector field is time independent, all three methods can generate the same result.

44
Tensor Algorithms 9 data values at each point

45
Tensor Algorithms Convert a tensor into three vectors (X) A X = X det |A- I| = 0 Using three eigenvalues and three eigenvectors: 1 2 3 X 1 X 2 X 3 Tensor ellipsoid: an ellipsoid drawn using the three eigenvectors as the major, medium, minor axis.

46
Tensor Algorithms

47
Modeling Algorithms For creating or changing dataset geometry or topology.

48
Modeling 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.

49
Modeling Algorithms Modeling Objects F(x,y,z) = x*x + y*y + z*z => Creates a data set with field value F(x i,y j,z k ); F(x,y,z) = 1.0; => Creates an Isosurface (a sphere object). Logical operations on two fields: F and G F G = min(F, G) F G = max(F,G) F - G = max(F-G)

50
Modeling 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.

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

Similar presentations

© 2016 SlidePlayer.com Inc.

All rights reserved.

Ads by Google