Presentation is loading. Please wait.

Presentation is loading. Please wait.

Visualization Chapter 12. CS 480/680Chapter 12 -- Visualization2 n Introduction: -In this chapter, we apply almost everything we have done so far to the.

Similar presentations


Presentation on theme: "Visualization Chapter 12. CS 480/680Chapter 12 -- Visualization2 n Introduction: -In this chapter, we apply almost everything we have done so far to the."— Presentation transcript:

1 Visualization Chapter 12

2 CS 480/680Chapter 12 -- Visualization2 n Introduction: -In this chapter, we apply almost everything we have done so far to the problem of visualizing large data sets that arise in scientific and medical applications. -Fortunately, we can bring many tools to bear on these problems We can create geometric objectsWe can create geometric objects We can color them, animate them, or change their orientation.We can color them, animate them, or change their orientation. -With all these possibilities, and others, there are multiple ways to visualize a given data set, and we will explore some of the possibilities in this chapter.

3 CS 480/680Chapter 12 -- Visualization3 1. Data + Geometry -Data comprise numbers. They are not geometric objects and thus they cannot be displayed directly by our graphics systems.They are not geometric objects and thus they cannot be displayed directly by our graphics systems. Only when we combine data with geometry are we able to create a display and to visualize the underlying information.Only when we combine data with geometry are we able to create a display and to visualize the underlying information. -A simple definition of (scientific) visualization is: the merging of data with the display of geometric objects through computer graphicsthe merging of data with the display of geometric objects through computer graphics

4 CS 480/680Chapter 12 -- Visualization4 n We consider three types of problems: -scalar visualization: we are given a three-dimensional volume of scalars, such as X-ray densities.we are given a three-dimensional volume of scalars, such as X-ray densities. -vector visualization: we start with a volume of vector data, such as the velocity at each point in a fluidwe start with a volume of vector data, such as the velocity at each point in a fluid -tensor visualization: we have a matrix of data at each point, such as the stresses within a mechanical part.we have a matrix of data at each point, such as the stresses within a mechanical part.

5 CS 480/680Chapter 12 -- Visualization5 -We must confront several difficulties One is the large size of the data sets.One is the large size of the data sets. –Many of the most interesting applications involve data that are measured over three spatial dimensions and often also in time. For example, the medical data such as from an MRI can be at a resolution of 512 x 512 x 200 points.For example, the medical data such as from an MRI can be at a resolution of 512 x 512 x 200 points. The visible-woman data set is a volume of densities that consist of 1734 x 512 x 512 data points.The visible-woman data set is a volume of densities that consist of 1734 x 512 x 512 data points. –consequently, we cannot assume that any operation on our data, no matter how conceptually simple it appears, can be carried out easily

6 CS 480/680Chapter 12 -- Visualization6 Second, these data are only dataSecond, these data are only data –They are not geometric objects –Thus we must translate these data to create and manipulate geometric objects. Third, we may have multidimensional data pointsThird, we may have multidimensional data points –For example, When we measure the flow of a fluid at a point, we are measuring the velocity, a three- dimensional quantity.When we measure the flow of a fluid at a point, we are measuring the velocity, a three- dimensional quantity. When we measure the stress or strain on a solid body at some internal point, we collect a 3x3 matrix of data.When we measure the stress or strain on a solid body at some internal point, we collect a 3x3 matrix of data. –How we convert these data to geometric objects and select the attributes of those objects determines the variety of visualization strategies.

7 CS 480/680Chapter 12 -- Visualization7 2. Height Fields and Contours -One of the most basic and important tasks in visualization is visualizing the structure in a mathematical function. -This problem arises in many forms, the biggest difference is how we are given the functionhow we are given the function –implicitly, explicitly, or parametrically. And in how many independent variables define the function.And in how many independent variables define the function.

8 CS 480/680Chapter 12 -- Visualization8 -In this section, we consider two problems that lead to similar visualization methods One is the visualization of an explicit function of the form:One is the visualization of an explicit function of the form: z = f(x,y)z = f(x,y) –with two dependent variables –Such functions are sometimes called height fields

9 CS 480/680Chapter 12 -- Visualization9 The second form is an implicit function in two variables:The second form is an implicit function in two variables: g(x,y) = cg(x,y) = c –where c is a constant. –This equation describes one or more two- dimensional curves in the x,y plane. There may also be no x,y values that satisfy the equation. –This curve is called the contour curve, corresponding to c

10 CS 480/680Chapter 12 -- Visualization10 n 2.1 Meshes -The most common method to display a function f(x,y) is to draw a surface. If the function f is known only discretely, then we have a set of samples or measurements of experimental data of the form:If the function f is known only discretely, then we have a set of samples or measurements of experimental data of the form: –z ij = f(x i,y j ) –We assume that the data are evenly spaced. If f is known analytically, then we can sample it to obtain a set of discrete data with which to work.If f is known analytically, then we can sample it to obtain a set of discrete data with which to work.

11 CS 480/680Chapter 12 -- Visualization11 -One simple way to generate a surface is through either a triangular or a quadrilateral mesh. Thus the data define a mesh of eitherThus the data define a mesh of either –NM quadrilaterals or –2NM triangles. The corresponding OpenGL programs are simple.The corresponding OpenGL programs are simple. The following figure shows a rectangular mesh from height data for a part of Honolulu, HawaiiThe following figure shows a rectangular mesh from height data for a part of Honolulu, Hawaii

12 CS 480/680Chapter 12 -- Visualization12 -There are interesting aspects to and modifications we can make to the OpenGL program First, if we use all the data, the resulting plot may contain many small polygonsFirst, if we use all the data, the resulting plot may contain many small polygons –The resulting line density may be annoying and can lead to moiré patterns –Hence we might prefer to sub-sample the data use every k th point for some kuse every k th point for some k or by averaging groups of data to obtain a new set of samples with smaller N and M.or by averaging groups of data to obtain a new set of samples with smaller N and M.

13 CS 480/680Chapter 12 -- Visualization13 Second, the figure we saw was drawn with both black lines and white filled polygons.Second, the figure we saw was drawn with both black lines and white filled polygons. –The lines are necessary to display the mesh. –The polygons are necessary to hide data behind the mesh. –If we display the data by first drawing the polygons in back and then proceed towards the front, the front polygons automatically hide the polygons further back. Since the data is well-structured, this is possible.Since the data is well-structured, this is possible. If hidden surface removal is done in software, this might be faster than turning on z-buffering.If hidden surface removal is done in software, this might be faster than turning on z-buffering.

14 CS 480/680Chapter 12 -- Visualization14 There is one additional trick that we used to display this figure.There is one additional trick that we used to display this figure. –If we draw both a polygon and a line loop with the same data, such as: glcolor3f(1.0,1.0,1.0);glcolor3f(1.0,1.0,1.0); glBegin(GL_QUADS)glBegin(GL_QUADS)...glVertex3i(...)...glVertex3i(...) glEnd();glEnd(); glColor3f(0.0,0.0,0.0);glColor3f(0.0,0.0,0.0); glBegin(GL_LINE_LOOP);glBegin(GL_LINE_LOOP);...glVertex3i(...)...glVertex3i(...) glEnd();glEnd(); –then the polygon and the line loop are in the same plane.

15 CS 480/680Chapter 12 -- Visualization15 –Even though the line loop is rendered after the polygon, numerical inaccuracies in the renderer often cause part of the line loop to be blocked by the polygon. –We can enable the polygon offset mode and se the offset parameter as in: glEnable(GL_POLYGON_OFFSET_FIL)glEnable(GL_POLYGON_OFFSET_FIL) glPolygonOffset(1.0, 0.5)glPolygonOffset(1.0, 0.5) –These functions move the lines slightly toward the viewer relative to the polygon, so all the desired lines are now visible.

16 CS 480/680Chapter 12 -- Visualization16 The basic mesh plot can be extended in many ways.The basic mesh plot can be extended in many ways. –If we display only the polygons then we can add lighting to create a realistic image of a surface in mapping applications. The required normals can be computed from the vertices of the triangles or quadrilaterals.The required normals can be computed from the vertices of the triangles or quadrilaterals. –Another option is to map a texture to the surface The texture map might be an image of the terrain from a photograph or other information that might be obtained by digitization of a map.The texture map might be an image of the terrain from a photograph or other information that might be obtained by digitization of a map. –If we combine these techniques, we can generate a display in which, by changing the position of the light source, we can make the image depend on the time of day.

17 CS 480/680Chapter 12 -- Visualization17 n 2.2 Contour Plots -One of the difficulties with mesh plots is that, although they give a visual impression of the data, it is difficult to make measurements from them. -An alternative method of displaying the height data is to display contours -- curves that correspond to a fixed value of height. We can use this method to construct topographic maps used by geologists and hikers.We can use this method to construct topographic maps used by geologists and hikers. The use of contours is still important, both on its own and as part of other visualization techniques.The use of contours is still important, both on its own and as part of other visualization techniques. We solve the accuracy problem of sampled data by using a technique called marching squaresWe solve the accuracy problem of sampled data by using a technique called marching squares

18 CS 480/680Chapter 12 -- Visualization18 n 2.3 Marching Squares -Suppose: we have a function f(x,y) that we sample at evenly spaced points on a rectangular array (or lattice) in x and y.we have a function f(x,y) that we sample at evenly spaced points on a rectangular array (or lattice) in x and y. that we would like to find an approximate contour curvethat we would like to find an approximate contour curve Our strategy is to construct a curve of connected line segments (piecewise linear)Our strategy is to construct a curve of connected line segments (piecewise linear) -We start with a rectangular cell determined by four grid points

19 CS 480/680Chapter 12 -- Visualization19 -Our algorithm finds the line segments on a cell-by- cell basis using only the values of z at the corners of the cell to determine whether the desired contour passes through the cell. -Consider this case

20 CS 480/680Chapter 12 -- Visualization20 -Then the contour line will go through the box, similar to the figure below. -The principle to consider is: When there are multiple possible explanations of a phenomenon that are consistent with the data, choose the simplest one.When there are multiple possible explanations of a phenomenon that are consistent with the data, choose the simplest one.

21 CS 480/680Chapter 12 -- Visualization21 -Returning to our example: We can now draw the line for this cell. The issue is where do we draw it?We can now draw the line for this cell. The issue is where do we draw it? –Pick the mid point on each edge and connect them –Interpolate the crossing points. -There are 16 (2 4 )ways that we can color the vertices of a cell using only black and white. All could arise in our contour problem.All could arise in our contour problem. These cases are itemized on the next slideThese cases are itemized on the next slide

22 CS 480/680Chapter 12 -- Visualization22

23 CS 480/680Chapter 12 -- Visualization23 -If we study these cases, we see that there are two types of symmetry Rotational (1 & 2)Rotational (1 & 2) Inverses (0 & 15)Inverses (0 & 15) Once we take symmetry into account, only 4 cases truly are unique:Once we take symmetry into account, only 4 cases truly are unique:

24 CS 480/680Chapter 12 -- Visualization24 The first case has no lineThe first case has no line The second case is what we just discussed.The second case is what we just discussed. The third case has a line from side to sideThe third case has a line from side to side The fourth case is ambiguous since there are two equally valid interpretationsThe fourth case is ambiguous since there are two equally valid interpretations

25 CS 480/680Chapter 12 -- Visualization25 We have no reason to prefer one over the otherWe have no reason to prefer one over the other –so we could pick one at random. –Always use only one possibility –... –But as this figure shows, we get different results depending upon the interpretation we choose

26 CS 480/680Chapter 12 -- Visualization26 Another possibility is to subdivide the cell into four smaller cells,Another possibility is to subdivide the cell into four smaller cells, and then draw our lines.and then draw our lines. The code is fairly simple:The code is fairly simple: int cell(double a, double b, double c, double d)int cell(double a, double b, double c, double d) { int num=0; int num=0; if(a>THRESHOLD) num+=1; if(a>THRESHOLD) num+=1; if(b>THRESHOLD) num+=8; if(b>THRESHOLD) num+=8; if(c>THRESHOLD) num+=4; if(c>THRESHOLD) num+=4; if(d>THRESHOLD) num+=2; if(d>THRESHOLD) num+=2; return num; return num; }

27 CS 480/680Chapter 12 -- Visualization27 We then can assign the cell to one of the four cases by:We then can assign the cell to one of the four cases by: switch(num){switch(num){ case 1: case 2: case 4: case 7: case 8: case 1: case 2: case 4: case 7: case 8: case 11: case 13: case 14: case 11: case 13: case 14: draw_one(num, i,j,a,b,c,d); draw_one(num, i,j,a,b,c,d); break; // contour cuts off one corner break; // contour cuts off one corner case 3: case 6: case 9: case 12: case 3: case 6: case 9: case 12: draw_adjacent(num,i,j,a,b,c,d); draw_adjacent(num,i,j,a,b,c,d); break; // contour crosses cell break; // contour crosses cell case 5: case 10: case 5: case 10: draw_opposite(num, i, j, a,b,c,d); draw_opposite(num, i, j, a,b,c,d); break; // ambiguous cases break; // ambiguous cases case 0: case 15: case 0: case 15: break; // no contour in cell break; // no contour in cell }

28 CS 480/680Chapter 12 -- Visualization28 -void draw_one(int num, int i, int j, double a, double b, - double c, double d) { - // compute the lower left corner of the cell and s_x and s_y here. - switch(num){ - case 1: case 14: - x1=ox; y1 = oy+s_y; - x2= ox+s_x; y2 = oy; - break; - /* the other cases go here - case 2: case 13:... - case 4: case 11:... - Case 7: case 8:... - } - glBegin(GL_LINES); - glVertex2d(x1,y1); - glvertex2d(x2,y2); - glEnd(); -}-}-}-}

29 CS 480/680Chapter 12 -- Visualization29 -The following figure shows two curves corresponding to a single contour value for: f(x,y) = (x 2 +y 2 +a 2 ) 2 -4a 2 x 2 -b 4 (with a=0.49, b=0.5)f(x,y) = (x 2 +y 2 +a 2 ) 2 -4a 2 x 2 -b 4 (with a=0.49, b=0.5) The function was sampled on a 50x50 gridThe function was sampled on a 50x50 grid The left uses midpoint, the right interpolation.The left uses midpoint, the right interpolation.

30 CS 480/680Chapter 12 -- Visualization30 -This next figure shows the Honolulu data set with equally spaced contours: The Marching squares algorithm just described is nice because all the cells are independent.The Marching squares algorithm just described is nice because all the cells are independent.

31 CS 480/680Chapter 12 -- Visualization31 3. Visualizing Surfaces and Scalar Fields -The surface and contour problems just described have three-dimensional extensions. f(x,y,z) defines a scalar field.f(x,y,z) defines a scalar field. An example is the density inside an object or the absorption of X-rays in the human body.An example is the density inside an object or the absorption of X-rays in the human body.

32 CS 480/680Chapter 12 -- Visualization32 Visualization of scalar fields is more difficult than the problems we have considered so far for two reasons:Visualization of scalar fields is more difficult than the problems we have considered so far for two reasons: –First, three-dimensional problems have more data with which we must work. Consequently, operations that are routine for 2D data (reading files and performing transformations) present practical difficulties.Consequently, operations that are routine for 2D data (reading files and performing transformations) present practical difficulties. –Second, when we had a problem with two independent variables, we were able to use the third dimension to visualize scalars. When we have three, we lack the extra dimension to use for display.When we have three, we lack the extra dimension to use for display. –Nevertheless, if we are careful, we can extend our previously developed methods to visualize three- dimensional scalar fields

33 CS 480/680Chapter 12 -- Visualization33 n 3.1 Volumetric Data Sets -Once again, assume that our samples are taken at equally spaced points in x,y, and z -The little boxes are called volume elements or voxels

34 CS 480/680Chapter 12 -- Visualization34 -Even more so than for two-dimensional data, there are multiple ways to display these data sets. -However there are two basic approaches: Direct Volume RenderingDirect Volume Rendering –makes use of every voxel in producing an image IsosurfacesIsosurfaces –use only a subset of the voxels

35 CS 480/680Chapter 12 -- Visualization35 n 3.2 Visualization of Implicit Functions -This is the natural extension of contours to 3D -Consider the implicit function in three dimensions g(x,y,z) = 0 where g is known analytically.g(x,y,z) = 0 where g is known analytically. One way to attack this problem involves a simple form of ray tracing (ray casting)One way to attack this problem involves a simple form of ray tracing (ray casting)

36 CS 480/680Chapter 12 -- Visualization36 -Finding isosurfaces usually involves working with a discretized version of the problem replacing g by a set of samples taken over some grid.replacing g by a set of samples taken over some grid. -Our prime isosurface visualization method is called marching cubes, the three-dimensional version of marching squares.

37 CS 480/680Chapter 12 -- Visualization37 4. Isosurfaces and Marching Cubes -Assume that we have a data set, where each voxel is a sample of the scalar field f(x,y,z) Eight adjacent grid points define a three- dimensional cell as shown here:Eight adjacent grid points define a three- dimensional cell as shown here:

38 CS 480/680Chapter 12 -- Visualization38 -We can now look for parts of isosurfaces that pass through these cells, based only on the values at the vertices. -There are 256=2 8 possible vertex colorings, but once we account for symmetries, there are only 14 unique cases

39 CS 480/680Chapter 12 -- Visualization39 -Using the simplest interpretation of the data, we can generate the points of intersection between the surface and the edges of the cubes by linear intepolation. -Finally we can use the triangle polygons to tesselate these intersections.

40 CS 480/680Chapter 12 -- Visualization40 -Because the algorithm is so easy to parallelize and, like the contour plot, can be table driven, marching cubes is a popular way of displaying three-dimensional data. -There is an ambiguity problem analogous to the one for contour maps

41 CS 480/680Chapter 12 -- Visualization41 5. Direct Volume Rendering -The weakness of isosurface rendering is that not all voxels contribute to the final image. Consequently, we could miss the most important part of the data by selecting the wrong isovalue.Consequently, we could miss the most important part of the data by selecting the wrong isovalue. -Direct volume rendering constructs images in which all voxels can make a contribution to the image.

42 CS 480/680Chapter 12 -- Visualization42 -Early methods for direct volume rendering treated each voxel as a small cube that was either transparent or completely opaque. These techniques produced images with serious aliasing artifacts.These techniques produced images with serious aliasing artifacts. -With the use of color and opacity, we can avoid or mitigate these problems.

43 CS 480/680Chapter 12 -- Visualization43 n 5.1 Assignment of Color and Opacity

44 CS 480/680Chapter 12 -- Visualization44 n 5.2 Splatting

45 CS 480/680Chapter 12 -- Visualization45 n 5.3 Volume Ray Tracing

46 CS 480/680Chapter 12 -- Visualization46 n 5.4 Texture Mapping of Volumes

47 CS 480/680Chapter 12 -- Visualization47 6. Vector Field Visualization -Our first visualization task considered a scalar field f(x,y,z) defined over a volume of space. -Now suppose that at each spatial point, we measure not a single value but rather a vector of n values. For example, in fluid-flow problems, we might measure the velocity at each point.For example, in fluid-flow problems, we might measure the velocity at each point. -Our visualization techniques for three-dimensional vector fields employ two primary tools: color and geometric objects.color and geometric objects.

48 CS 480/680Chapter 12 -- Visualization48 n 6.1 Hedgehogs

49 CS 480/680Chapter 12 -- Visualization49 n 6.2 Glyphs

50 CS 480/680Chapter 12 -- Visualization50 n 6.3 Color

51 CS 480/680Chapter 12 -- Visualization51 n 6.4 Particle Traces and Streamlines

52 CS 480/680Chapter 12 -- Visualization52 7. Tensor Visualization -We use tensor visualization when we have data that are themselves related spatially. -For example, we might measure stress or strain at every point within a solid material that is subject to external forces. The stress at a point (x,y,z) in the material can be described by a 3x3 matrixThe stress at a point (x,y,z) in the material can be described by a 3x3 matrix

53 CS 480/680Chapter 12 -- Visualization53 -One method of visualization is to display small cubes, each of which has been distorted by the local stress matrix. -Another method is to display properties of the matrix. For example, if the matrix is symmetric then we can decompose it into its eigenvalues and eigenvectorsFor example, if the matrix is symmetric then we can decompose it into its eigenvalues and eigenvectors –the eigenvalues are the most important characteristic of a matrix. –Then you can associate an ellipsoid with the three eigenvalues the eigenvalues determine the length of the three axes of the ellipsethe eigenvalues determine the length of the three axes of the ellipse the eigenvectors determine the orientationthe eigenvectors determine the orientation

54 CS 480/680Chapter 12 -- Visualization54 8. Summary -Although visualization encompasses everything we don in computer graphics, recent work in visualization has focused on the large data sets that arise in medical applications and from scientific simulations. These data sets are so large that not only can they burden the best of hardware, but also conceptually simple operations (rendering, repositioning data) can be difficult.These data sets are so large that not only can they burden the best of hardware, but also conceptually simple operations (rendering, repositioning data) can be difficult.

55 CS 480/680Chapter 12 -- Visualization55 -For volumetric data sets of scalars, we have introduced two general approaches: isosurfaces and volume rendering. These techniques are fast and construct geometric objects that can be manipulated interactively.These techniques are fast and construct geometric objects that can be manipulated interactively. Their weakness is that they do not make use of all the data.Their weakness is that they do not make use of all the data. -Vector-visualization techniques are most important in flow visualization Here we have sought to show patterns of flow through a variety of techniques including hedgehogs, glyphs, streamlines, and particle traces.Here we have sought to show patterns of flow through a variety of techniques including hedgehogs, glyphs, streamlines, and particle traces.

56 CS 480/680Chapter 12 -- Visualization56 -For problems in which we have data of more than three dimensions at each point, including tensor visualization, t is less clear how we should visualize the information. -The difficulties are twofold First, our graphics systems can display only three- dimensional primitives.First, our graphics systems can display only three- dimensional primitives. Second, although we can use other variables, such as color, to increase the “dimension” of the display, human observers may have difficulty interpreting such displaysSecond, although we can use other variables, such as color, to increase the “dimension” of the display, human observers may have difficulty interpreting such displays

57 CS 480/680Chapter 12 -- Visualization57 9. Suggested Readings -The marching-squares method is a special case of the marching cubes method popularized by Lorenson and Kline (87) This method has been rediscovered many times.This method has been rediscovered many times. -Early attempts to visualize volumes were reported by Herman (79) and by Fuchs (77) -Ray Tracing volumes was introduced in ‘88, Splatting in ‘90, and particles in ‘94

58 CS 480/680Chapter 12 -- Visualization58 -Many other visualization strategies are discussed in Glassner’s book -One approach to building visualization applications is to use an object oriented toolkit. This was presented in The Visualization Toolkit by Schroeder, et.al. -The IEEE Transactions on Visualization and Computer Graphics contain many examples of recent work in Scientific Visualization.

59 CS 480/680Chapter 12 -- Visualization59 Exercises -- Due next class


Download ppt "Visualization Chapter 12. CS 480/680Chapter 12 -- Visualization2 n Introduction: -In this chapter, we apply almost everything we have done so far to the."

Similar presentations


Ads by Google