visualization chapter 12. cs 480/680chapter 12 -- visualization2 n introduction: -in this chapter,...

59
Visualization Visualization Chapter 12 Chapter 12

Upload: barbara-edwards

Post on 16-Jan-2016

218 views

Category:

Documents


0 download

TRANSCRIPT

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

VisualizationVisualization

Chapter 12Chapter 12

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

CS 480/680 Chapter 12 -- Visualization 2

Introduction:Introduction:- In this chapter, we apply almost everything we have In this chapter, we apply almost everything we have

done so far to the problem of visualizing large data done so far to the problem of visualizing large data sets that arise in scientific and medical applications.sets that arise in scientific and medical applications.

- Fortunately, we can bring many tools to bear on Fortunately, we can bring many tools to bear on these problemsthese problems

• We can create geometric objectsWe can create geometric objects• We can color them, animate them, or change their We can color them, animate them, or change their

orientation.orientation.

- With all these possibilities, and others, there are With all these possibilities, and others, there are multiple ways to visualize a given data set, and we multiple ways to visualize a given data set, and we will explore some of the possibilities in this chapter.will explore some of the possibilities in this chapter.

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

CS 480/680 Chapter 12 -- Visualization 3

1. Data + Geometry1. Data + Geometry

- Data comprise numbers. Data comprise numbers. • They are not geometric objects and thus they They are not geometric objects and thus they

cannot be displayed directly by our graphics cannot be displayed directly by our graphics systems.systems.

• Only when we combine data with geometry are we Only when we combine data with geometry are we able to create a display and to visualize the able to create a display and to visualize the underlying information.underlying information.

- A simple definition of (scientific) visualization is:A simple definition of (scientific) visualization is:• the merging of data with the display of geometric the merging of data with the display of geometric

objects through computer graphicsobjects through computer graphics

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

CS 480/680 Chapter 12 -- Visualization 4

We consider three types of problems:We consider three types of problems:- scalar visualizationscalar visualization::

• we are given a three-dimensional volume of we are given a three-dimensional volume of scalars, such as X-ray densities.scalars, such as X-ray densities.

- vector visualizationvector visualization::• we start with a volume of vector data, such as the we start with a volume of vector data, such as the

velocity at each point in a fluidvelocity at each point in a fluid

- tensor visualizationtensor visualization::• we have a matrix of data at each point, such as the we have a matrix of data at each point, such as the

stresses within a mechanical part.stresses within a mechanical part.

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

CS 480/680 Chapter 12 -- Visualization 5

- We must confront several difficultiesWe 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 Many of the most interesting applications involve data that are measured over three spatial data that are measured over three spatial dimensions and often also in time.dimensions and often also in time.

• For example, the medical data such as from an For example, the medical data such as from an MRI can be at a resolution of 512 x 512 x 200 MRI can be at a resolution of 512 x 512 x 200 points.points.

• The visible-woman data set is a volume of The visible-woman data set is a volume of densities that consist of 1734 x 512 x 512 data densities that consist of 1734 x 512 x 512 data points.points.

– consequently, we cannot assume that any operation consequently, we cannot assume that any operation on our data, no matter how conceptually simple it on our data, no matter how conceptually simple it appears, can be carried out easilyappears, can be carried out easily

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

CS 480/680 Chapter 12 -- Visualization 6

• Second, these data are only data Second, these data are only data – They are not geometric objectsThey are not geometric objects

– Thus we must translate these data to create and Thus we must translate these data to create and manipulate geometric objects.manipulate geometric objects.

• Third, we may have multidimensional data pointsThird, we may have multidimensional data points– For example, For example,

• When we measure the flow of a fluid at a point, we When we measure the flow of a fluid at a point, we are measuring the velocity, a three-dimensional are measuring the velocity, a three-dimensional quantity. quantity.

• When we measure the stress or strain on a solid When we measure the stress or strain on a solid body at some internal point, we collect a 3x3 body at some internal point, we collect a 3x3 matrix of data. matrix of data.

– How we convert these data to geometric objects and How we convert these data to geometric objects and select the attributes of those objects determines the select the attributes of those objects determines the variety of visualization strategies.variety of visualization strategies.

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

CS 480/680 Chapter 12 -- Visualization 7

2. Height Fields and Contours2. Height Fields and Contours

- One of the most basic and important tasks in One of the most basic and important tasks in visualization is visualizing the structure in a visualization is visualizing the structure in a mathematical function.mathematical function.

- This problem arises in many forms, the biggest This problem arises in many forms, the biggest difference is difference is

• how we are given the functionhow we are given the function– implicitly, explicitly, or parametrically.implicitly, explicitly, or parametrically.

• And in how many independent variables define the And in how many independent variables define the function.function.

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

CS 480/680 Chapter 12 -- Visualization 8

- In this section, we consider two problems that lead In this section, we consider two problems that lead to similar visualization methodsto similar visualization methods

• One is the visualization of an explicit function of the One is the visualization of an explicit function of the form:form:

• z = f(x,y)z = f(x,y)– with two dependent variableswith two dependent variables

– Such functions are sometimes called Such functions are sometimes called height fieldsheight fields

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

CS 480/680 Chapter 12 -- Visualization 9

• The second form is an implicit function in two The second form is an implicit function in two variables:variables:

• g(x,y) = cg(x,y) = c– where c is a constant.where c is a constant.

– This equation describes one or more two-This equation describes one or more two-dimensional curves in the x,y plane. There may also dimensional curves in the x,y plane. There may also be no x,y values that satisfy the equation.be no x,y values that satisfy the equation.

– This curve is called the This curve is called the contour curve,contour curve, corresponding to ccorresponding to c

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

CS 480/680 Chapter 12 -- Visualization 10

2.1 Meshes2.1 Meshes- The most common method to display a function The most common method to display a function

f(x,y) is to draw a surface.f(x,y) is to draw a surface.• If the function f is known only discretely, then we If the function f is known only discretely, then we

have a set of samples or measurements of have a set of samples or measurements of experimental data of the form:experimental data of the form:

– zzijij = f(x = f(xii,y,yjj))

– We assume that the data are evenly spaced.We assume that the data are evenly spaced.

• If f is known analytically, then we can sample it to If f is known analytically, then we can sample it to obtain a set of discrete data with which to work.obtain a set of discrete data with which to work.

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

CS 480/680 Chapter 12 -- Visualization 11

- One simple way to generate a surface is through One simple way to generate a surface is through either a triangular or a quadrilateral mesh.either a triangular or a quadrilateral mesh.

• Thus the data define a mesh of either Thus the data define a mesh of either – NMNM quadrilaterals or quadrilaterals or – 2NM2NM triangles. triangles.

• The corresponding OpenGL programs are simple.The corresponding OpenGL programs are simple.

• The following figure shows a rectangular mesh from The following figure shows a rectangular mesh from height data for a part of Honolulu, Hawaiiheight data for a part of Honolulu, Hawaii

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

CS 480/680 Chapter 12 -- Visualization 12

- There are interesting aspects to and modifications There are interesting aspects to and modifications we can make to the OpenGL programwe can make to the OpenGL program

• First, if we use all the data, the resulting plot may First, if we use all the data, the resulting plot may contain many small polygonscontain many small polygons

– The resulting line density may be annoying and can The resulting line density may be annoying and can lead to moiré patternslead to moiré patterns

– Hence we might prefer to sub-sample the dataHence we might prefer to sub-sample the data• use every use every kkthth point for some point for some kk• or by averaging groups of data to obtain a new or by averaging groups of data to obtain a new

set of samples with smaller set of samples with smaller NN and and MM..

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

CS 480/680 Chapter 12 -- Visualization 13

• Second, the figure we saw was drawn with both Second, the figure we saw was drawn with both black lines and white filled polygons.black lines and white filled polygons.

– The lines are necessary to display the mesh.The lines are necessary to display the mesh.

– The polygons are necessary to hide data behind the The polygons are necessary to hide data behind the mesh.mesh.

– If we display the data by first drawing the polygons in If we display the data by first drawing the polygons in back and then proceed towards the front, the front back and then proceed towards the front, the front polygons automatically hide the polygons further polygons automatically hide the polygons further back.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 If hidden surface removal is done in software, this might be faster than turning on z-buffering.might be faster than turning on z-buffering.

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

CS 480/680 Chapter 12 -- Visualization 14

• There is one additional trick that we used to display There is one additional trick that we used to display this figure. this figure.

– If we draw both a polygon and a line loop with the If we draw both a polygon and a line loop with the same data, such as: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 then the polygon and the line loop are in the same plane. plane.

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

CS 480/680 Chapter 12 -- Visualization 15

– Even though the line loop is rendered after the Even though the line loop is rendered after the polygon, numerical inaccuracies in the renderer polygon, numerical inaccuracies in the renderer often cause part of the line loop to be blocked by the often cause part of the line loop to be blocked by the polygon.polygon.

– We can enable the polygon offset mode and se the We can enable the polygon offset mode and se the offset parameter as in: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 These functions move the lines slightly toward the viewer relative to the polygon, so all the desired lines viewer relative to the polygon, so all the desired lines are now visible.are now visible.

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

CS 480/680 Chapter 12 -- Visualization 16

• The basic mesh plot can be extended in many The basic mesh plot can be extended in many ways.ways.

– If we display only the polygons then we can add If we display only the polygons then we can add lighting to create a realistic image of a surface in lighting to create a realistic image of a surface in mapping applications.mapping applications.

• The required normals can be computed from the The required normals can be computed from the vertices of the triangles or quadrilaterals.vertices of the triangles or quadrilaterals.

– Another option is to map a texture to the surfaceAnother option is to map a texture to the surface• The texture map might be an image of the terrain The texture map might be an image of the terrain

from a photograph or other information that from a photograph or other information that might be obtained by digitization of a map.might be obtained by digitization of a map.

– If we combine these techniques, we can generate a If we combine these techniques, we can generate a display in which, by changing the position of the light display in which, by changing the position of the light source, we can make the image depend on the time source, we can make the image depend on the time of day.of day.

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

CS 480/680 Chapter 12 -- Visualization 17

2.2 Contour Plots2.2 Contour Plots- One of the difficulties with mesh plots is that, One of the difficulties with mesh plots is that,

although they give a visual impression of the data, although they give a visual impression of the data, it is difficult to make measurements from them. it is difficult to make measurements from them.

- An alternative method of displaying the height data An alternative method of displaying the height data is to display contours -- curves that correspond to is to display contours -- curves that correspond to a fixed value of height.a fixed value of height.

• We can use this method to construct topographic We can use this method to construct topographic maps used by geologists and hikers.maps used by geologists and hikers.

• The use of contours is still important, both on its The use of contours is still important, both on its own and as part of other visualization techniques.own and as part of other visualization techniques.

• We solve the accuracy problem of sampled data by We solve the accuracy problem of sampled data by using a technique called marching squaresusing a technique called marching squares

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

CS 480/680 Chapter 12 -- Visualization 18

2.3 Marching Squares2.3 Marching Squares- Suppose:Suppose:

• we have a function f(x,y) that we sample at evenly we have a function f(x,y) that we sample at evenly spaced points on a rectangular array (or lattice) in x spaced points on a rectangular array (or lattice) in x and y.and y.

• that we would like to find an approximate contour that we would like to find an approximate contour curvecurve

• Our strategy is to construct a curve of connected Our strategy is to construct a curve of connected line segments (piecewise linear)line segments (piecewise linear)

- We start with a rectangular cell determined by four We start with a rectangular cell determined by four grid pointsgrid points

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

CS 480/680 Chapter 12 -- Visualization 19

- Our algorithm finds the line segments on a cell-by-Our algorithm finds the line segments on a cell-by-cell basis using only the values of z at the corners cell basis using only the values of z at the corners of the cell to determine whether the desired of the cell to determine whether the desired contour passes through the cell.contour passes through the cell.

- Consider this caseConsider this case

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

CS 480/680 Chapter 12 -- Visualization 20

- Then the contour line will go through the box, Then the contour line will go through the box, similar to the figure below.similar to the figure below.

- The principle to consider is:The principle to consider is:• When there are multiple possible explanations of a When there are multiple possible explanations of a

phenomenon that are consistent with the data, phenomenon that are consistent with the data, choose the simplest one.choose the simplest one.

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

CS 480/680 Chapter 12 -- Visualization 21

- Returning to our example:Returning to our example:• We can now draw the line for this cell. The issue is We can now draw the line for this cell. The issue is

where do we draw it?where do we draw it?– Pick the mid point on each edge and connect themPick the mid point on each edge and connect them– Interpolate the crossing points.Interpolate the crossing points.

- There are 16 (2There are 16 (244)ways that we can color the )ways that we can color the vertices of a cell using only black and white.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

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

CS 480/680 Chapter 12 -- Visualization 22

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

CS 480/680 Chapter 12 -- Visualization 23

- If we study these cases, we see that there are two If we study these cases, we see that there are two types of symmetrytypes of symmetry

• Rotational (1 & 2)Rotational (1 & 2)

• Inverses (0 & 15)Inverses (0 & 15)

• Once we take symmetry into account, only 4 cases Once we take symmetry into account, only 4 cases truly are unique:truly are unique:

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

CS 480/680 Chapter 12 -- Visualization 24

• 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 The fourth case is ambiguous since there are two equally valid interpretationsequally valid interpretations

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

CS 480/680 Chapter 12 -- Visualization 25

• 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.so we could pick one at random.– Always use only one possibilityAlways use only one possibility– ......

– But as this figure shows, we get different results But as this figure shows, we get different results depending upon the interpretation we choosedepending upon the interpretation we choose

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

CS 480/680 Chapter 12 -- Visualization 26

• Another possibility is to subdivide the cell into four Another possibility is to subdivide the cell into four smaller cells,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;• }}

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

CS 480/680 Chapter 12 -- Visualization 27

• We then can assign the cell to one of the four cases We then can assign the cell to one of the four cases by: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 cornerbreak; // 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 cellbreak; // 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 casesbreak; // ambiguous cases

• case 0: case 15: case 0: case 15:

• break; // no contour in cellbreak; // no contour in cell

• }}

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

CS 480/680 Chapter 12 -- Visualization 28

- void draw_one(int num, int i, int j, double a, double b, void draw_one(int num, int i, int j, double a, double b,

- double c, double d) {double c, double d) {

- // compute the lower left corner of the cell and s_x and s_y here.// compute the lower left corner of the cell and s_x and s_y here.

- switch(num){switch(num){

- case 1: case 14:case 1: case 14:

- x1=ox; y1 = oy+s_y;x1=ox; y1 = oy+s_y;

- x2= ox+s_x; y2 = oy;x2= ox+s_x; y2 = oy;

- break;break;

- /* the other cases go here/* the other cases go here

- case 2: case 13: ...case 2: case 13: ...

- case 4: case 11: ...case 4: case 11: ...

- Case 7: case 8: ...Case 7: case 8: ...

- }}

- glBegin(GL_LINES);glBegin(GL_LINES);

- glVertex2d(x1,y1);glVertex2d(x1,y1);

- glvertex2d(x2,y2);glvertex2d(x2,y2);

- glEnd();glEnd();

- }}

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

CS 480/680 Chapter 12 -- Visualization 29

- The following figure shows two curves The following figure shows two curves corresponding to a single contour value for:corresponding to a single contour value for:

• f(x,y) = (xf(x,y) = (x22+y+y22+a+a22))22-4a-4a22xx22-b-b44 (with a=0.49, b=0.5) (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.

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

CS 480/680 Chapter 12 -- Visualization 30

- This next figure shows the Honolulu data set with This next figure shows the Honolulu data set with equally spaced contours:equally spaced contours:

• The Marching squares algorithm just described is The Marching squares algorithm just described is nice because all the cells are independent.nice because all the cells are independent.

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

CS 480/680 Chapter 12 -- Visualization 31

3. Visualizing Surfaces and 3. Visualizing Surfaces and Scalar FieldsScalar Fields

- The surface and contour problems just described The surface and contour problems just described have three-dimensional extensions.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 An example is the density inside an object or the absorption of X-rays in the human body.absorption of X-rays in the human body.

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

CS 480/680 Chapter 12 -- Visualization 32

• Visualization of scalar fields is more difficult than Visualization of scalar fields is more difficult than the problems we have considered so far for two the problems we have considered so far for two reasons:reasons:

– First, three-dimensional problems have more data First, three-dimensional problems have more data with which we must work. with which we must work.

• Consequently, operations that are routine for 2D Consequently, operations that are routine for 2D data (reading files and performing data (reading files and performing transformations) present practical difficulties.transformations) present practical difficulties.

– Second, when we had a problem with two Second, when we had a problem with two independent variables, we were able to use the third independent variables, we were able to use the third dimension to visualize scalars. dimension to visualize scalars.

• When we have three, we lack the extra When we have three, we lack the extra dimension to use for display.dimension to use for display.

– Nevertheless, if we are careful, we can extend our Nevertheless, if we are careful, we can extend our previously developed methods to visualize three-previously developed methods to visualize three-dimensional scalar fieldsdimensional scalar fields

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

CS 480/680 Chapter 12 -- Visualization 33

3.1 Volumetric Data Sets3.1 Volumetric Data Sets- Once again, assume that our samples are taken at Once again, assume that our samples are taken at

equally spaced points in x,y, and zequally spaced points in x,y, and z

- The little boxes are called volume elements or The little boxes are called volume elements or voxelsvoxels

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

CS 480/680 Chapter 12 -- Visualization 34

- Even more so than for two-dimensional data, there Even more so than for two-dimensional data, there are multiple ways to display these data sets. are multiple ways to display these data sets.

- However there are two basic approaches:However there are two basic approaches:• Direct Volume RenderingDirect Volume Rendering

– makes use of every voxel in producing an imagemakes use of every voxel in producing an image

• IsosurfacesIsosurfaces– use only a subset of the voxelsuse only a subset of the voxels

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

CS 480/680 Chapter 12 -- Visualization 35

3.2 Visualization of Implicit Functions3.2 Visualization of Implicit Functions- This is the natural extension of contours to 3DThis is the natural extension of contours to 3D

- Consider the implicit function in three dimensionsConsider 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 One way to attack this problem involves a simple form of ray tracing (ray casting)form of ray tracing (ray casting)

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

CS 480/680 Chapter 12 -- Visualization 36

- Finding isosurfaces usually involves working with Finding isosurfaces usually involves working with a discretized version of the problema discretized version of the problem

• replacing g by a set of samples taken over some replacing g by a set of samples taken over some grid.grid.

- Our prime isosurface visualization method is Our prime isosurface visualization method is called marching cubes, the three-dimensional called marching cubes, the three-dimensional version of marching squares.version of marching squares.

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

CS 480/680 Chapter 12 -- Visualization 37

4. Isosurfaces and Marching 4. Isosurfaces and Marching CubesCubes

- Assume that we have a data set, where each Assume that we have a data set, where each voxel is a sample of the scalar field f(x,y,z)voxel is a sample of the scalar field f(x,y,z)

• Eight adjacent grid points define a three-Eight adjacent grid points define a three-dimensional cell as shown here:dimensional cell as shown here:

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

CS 480/680 Chapter 12 -- Visualization 38

- We can now look for parts of isosurfaces that We can now look for parts of isosurfaces that pass through these cells, based only on the values pass through these cells, based only on the values at the vertices.at the vertices.

- There are 256=2There are 256=288 possible vertex colorings, but possible vertex colorings, but once we account for symmetries, there are only 14 once we account for symmetries, there are only 14 unique casesunique cases

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

CS 480/680 Chapter 12 -- Visualization 39

- Using the simplest interpretation of the data, we Using the simplest interpretation of the data, we can generate the points of intersection between can generate the points of intersection between the surface and the edges of the cubes by linear the surface and the edges of the cubes by linear intepolation.intepolation.

- Finally we can use the triangle polygons to Finally we can use the triangle polygons to tesselate these intersections.tesselate these intersections.

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

CS 480/680 Chapter 12 -- Visualization 40

- Because the algorithm is so easy to parallelize Because the algorithm is so easy to parallelize and, like the contour plot, can be table driven, and, like the contour plot, can be table driven, marching cubes is a popular way of displaying marching cubes is a popular way of displaying three-dimensional data.three-dimensional data.

- There is an ambiguity problem analogous to the There is an ambiguity problem analogous to the one for contour mapsone for contour maps

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

CS 480/680 Chapter 12 -- Visualization 41

5. Direct Volume Rendering5. Direct Volume Rendering

- The weakness of isosurface rendering is that not The weakness of isosurface rendering is that not all voxels contribute to the final image.all voxels contribute to the final image.

• Consequently, we could miss the most important Consequently, we could miss the most important part of the data by selecting the wrong isovalue.part of the data by selecting the wrong isovalue.

- Direct volume rendering constructs images in Direct volume rendering constructs images in which all voxels can make a contribution to the which all voxels can make a contribution to the image.image.

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

CS 480/680 Chapter 12 -- Visualization 42

- Early methods for direct volume rendering treated Early methods for direct volume rendering treated each voxel as a small cube that was either each voxel as a small cube that was either transparent or completely opaque.transparent or completely opaque.

• These techniques produced images with serious These techniques produced images with serious aliasing artifacts.aliasing artifacts.

- With the use of color and opacity, we can avoid or With the use of color and opacity, we can avoid or mitigate these problems.mitigate these problems.

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

CS 480/680 Chapter 12 -- Visualization 43

5.1 Assignment of Color and Opacity5.1 Assignment of Color and Opacity

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

CS 480/680 Chapter 12 -- Visualization 44

5.2 Splatting5.2 Splatting

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

CS 480/680 Chapter 12 -- Visualization 45

5.3 Volume Ray Tracing5.3 Volume Ray Tracing

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

CS 480/680 Chapter 12 -- Visualization 46

5.4 Texture Mapping of Volumes5.4 Texture Mapping of Volumes

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

CS 480/680 Chapter 12 -- Visualization 47

6. Vector Field Visualization6. Vector Field Visualization

- Our first visualization task considered a scalar field Our first visualization task considered a scalar field f(x,y,z) defined over a volume of space. f(x,y,z) defined over a volume of space.

- Now suppose that at each spatial point, we Now suppose that at each spatial point, we measure not a single value but rather a vector of n measure not a single value but rather a vector of n values.values.

• For example, in fluid-flow problems, we might For example, in fluid-flow problems, we might measure the velocity at each point.measure the velocity at each point.

- Our visualization techniques for three-dimensional Our visualization techniques for three-dimensional vector fields employ two primary tools:vector fields employ two primary tools:

• color and geometric objects.color and geometric objects.

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

CS 480/680 Chapter 12 -- Visualization 48

6.1 Hedgehogs6.1 Hedgehogs

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

CS 480/680 Chapter 12 -- Visualization 49

6.2 Glyphs6.2 Glyphs

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

CS 480/680 Chapter 12 -- Visualization 50

6.3 Color6.3 Color

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

CS 480/680 Chapter 12 -- Visualization 51

6.4 Particle Traces and Streamlines6.4 Particle Traces and Streamlines

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

CS 480/680 Chapter 12 -- Visualization 52

7. Tensor Visualization7. Tensor Visualization

- We use tensor visualization when we have data We use tensor visualization when we have data that are themselves related spatially.that are themselves related spatially.

- For example, we might measure stress or strain at For example, we might measure stress or strain at every point within a solid material that is subject to every point within a solid material that is subject to external forces.external forces.

• The stress at a point (x,y,z) in the material can be The stress at a point (x,y,z) in the material can be described by a 3x3 matrixdescribed by a 3x3 matrix

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

CS 480/680 Chapter 12 -- Visualization 53

- One method of visualization is to display small One method of visualization is to display small cubes, each of which has been distorted by the cubes, each of which has been distorted by the local stress matrix.local stress matrix.

- Another method is to display properties of the Another method is to display properties of the matrix.matrix.

• For example, if the matrix is symmetric then we can For example, if the matrix is symmetric then we can decompose it into its eigenvalues and eigenvectorsdecompose it into its eigenvalues and eigenvectors

– the eigenvalues are the most important characteristic the eigenvalues are the most important characteristic of a matrix. of a matrix.

– Then you can associate an ellipsoid with the three Then you can associate an ellipsoid with the three eigenvalueseigenvalues

• the eigenvalues determine the length of the three the eigenvalues determine the length of the three axes of the ellipseaxes of the ellipse

• the eigenvectors determine the orientationthe eigenvectors determine the orientation

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

CS 480/680 Chapter 12 -- Visualization 54

8. Summary8. Summary

- Although visualization encompasses everything Although visualization encompasses everything we don in computer graphics, recent work in we don in computer graphics, recent work in visualization has focused on the large data sets visualization has focused on the large data sets that arise in medical applications and from that arise in medical applications and from scientific simulations.scientific simulations.

• These data sets are so large that not only can they These data sets are so large that not only can they burden the best of hardware, but also conceptually burden the best of hardware, but also conceptually simple operations (rendering, repositioning data) simple operations (rendering, repositioning data) can be difficult.can be difficult.

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

CS 480/680 Chapter 12 -- Visualization 55

- For volumetric data sets of scalars, we have For volumetric data sets of scalars, we have introduced two general approaches: isosurfaces introduced two general approaches: isosurfaces and volume rendering.and volume rendering.

• These techniques are fast and construct geometric These techniques are fast and construct geometric objects that can be manipulated interactively.objects that can be manipulated interactively.

• Their weakness is that they do not make use of all Their weakness is that they do not make use of all the data.the data.

- Vector-visualization techniques are most important Vector-visualization techniques are most important in flow visualizationin flow visualization

• Here we have sought to show patterns of flow Here we have sought to show patterns of flow through a variety of techniques including through a variety of techniques including hedgehogs, glyphs, streamlines, and particle hedgehogs, glyphs, streamlines, and particle traces.traces.

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

CS 480/680 Chapter 12 -- Visualization 56

- For problems in which we have data of more than For problems in which we have data of more than three dimensions at each point, including tensor three dimensions at each point, including tensor visualization, t is less clear how we should visualization, t is less clear how we should visualize the information.visualize the information.

- The difficulties are twofoldThe difficulties are twofold• First, our graphics systems can display only three-First, our graphics systems can display only three-

dimensional primitives.dimensional primitives.

• Second, although we can use other variables, such Second, although we can use other variables, such as color, to increase the “dimension” of the display, as color, to increase the “dimension” of the display, human observers may have difficulty interpreting human observers may have difficulty interpreting such displayssuch displays

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

CS 480/680 Chapter 12 -- Visualization 57

9. Suggested Readings9. Suggested Readings

- The marching-squares method is a special case of The marching-squares method is a special case of the marching cubes method popularized by the marching cubes method popularized by Lorenson and Kline (87)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 Early attempts to visualize volumes were reported by Herman (79) and by Fuchs (77)by Herman (79) and by Fuchs (77)

- Ray Tracing volumes was introduced in ‘88, Ray Tracing volumes was introduced in ‘88, Splatting in ‘90, and particles in ‘94Splatting in ‘90, and particles in ‘94

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

CS 480/680 Chapter 12 -- Visualization 58

- Many other visualization strategies are discussed Many other visualization strategies are discussed in Glassner’s book in Glassner’s book

- One approach to building visualization applications One approach to building visualization applications is to use an object oriented toolkit. This was is to use an object oriented toolkit. This was presented in presented in The Visualization ToolkitThe Visualization Toolkit by by Schroeder, et.al.Schroeder, et.al.

- The The IEEE Transactions on Visualization and IEEE Transactions on Visualization and Computer GraphicsComputer Graphics contain many examples of contain many examples of recent work in Scientific Visualization.recent work in Scientific Visualization.

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

CS 480/680 Chapter 12 -- Visualization 59

Exercises -- Due next classExercises -- Due next class