visualization chapter 12. cs 480/680 2chapter 12 -- visualization introduction: introduction: in...

64
Visualization Visualization Chapter 12 Chapter 12

Upload: alban-carson

Post on 28-Jan-2016

224 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

VisualizationVisualization

Chapter 12Chapter 12

Page 2: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 2Chapter 12 -- Visualization

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

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

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

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

their orientation.their orientation.

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

Page 3: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 3Chapter 12 -- Visualization

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 Only when we combine data with geometry are we able to create a display and to visualize the we able to create a display and to visualize the underlying information.underlying information.

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

geometric objects through computer graphicsgeometric objects through computer graphics

Page 4: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 4Chapter 12 -- Visualization

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 we start with a volume of vector data, such

as the velocity at each point in a fluidas the velocity at each point in a fluid

tensor visualizationtensor visualization:: we have a matrix of data at each point, such we have a matrix of data at each point, such

as the stresses within a mechanical part.as the stresses within a mechanical part.

Page 5: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 5Chapter 12 -- Visualization

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

For example, the medical data such as For example, the medical data such as from an MRI can be at a resolution of 512 from an MRI can be at a resolution of 512 x 512 x 200 points.x 512 x 200 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 densities that consist of 1734 x 512 x 512 data points.data points.

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

Page 6: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 6Chapter 12 -- Visualization

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 Third, we may have multidimensional data pointspoints

For example, For example, When we measure the flow of a fluid at a point, When we measure the flow of a fluid at a point,

we are measuring the velocity, a three-we are measuring the velocity, a three-dimensional quantity. dimensional quantity.

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

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

Page 7: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 7Chapter 12 -- Visualization

2. Height Fields and 2. Height Fields and ContoursContours

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

This problem arises in many forms, the This problem arises in many forms, the biggest difference is biggest 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 And in how many independent variables

define the function.define the function.

Page 8: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 8Chapter 12 -- Visualization

In this section, we consider two In this section, we consider two problems that lead to similar problems that lead to similar visualization methodsvisualization methods One is the visualization of an explicit One is the visualization of an explicit

function of the form:function of the 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 height fieldsfields

Page 9: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 9Chapter 12 -- Visualization

The second form is an implicit function in The second form is an implicit function in two variables:two 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 dimensional curves in the x,y plane. There may also be no x,y values that satisfy the may also be no x,y values that satisfy the equation.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/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 10Chapter 12 -- Visualization

2.1 Meshes2.1 Meshes The most common method to display The most common method to display

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

then we have a set of samples or then we have a set of samples or measurements of experimental data of measurements of experimental data of the form: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 If f is known analytically, then we can sample it to obtain a set of discrete data sample it to obtain a set of discrete data with which to work.with which to work.

Page 11: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 11Chapter 12 -- Visualization

One simple way to generate a surface One simple way to generate a surface is through either a triangular or a is through either a triangular or a quadrilateral mesh.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 The corresponding OpenGL programs are simple.are simple.

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

Page 12: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 12Chapter 12 -- Visualization

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

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

The resulting line density may be annoying The resulting line density may be annoying and can lead to moiré patternsand can lead 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 or by averaging groups of data to obtain a

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

Page 13: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 13Chapter 12 -- Visualization

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

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

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

If we display the data by first drawing the If we display the data by first drawing the polygons in back and then proceed towards polygons in back and then proceed towards the front, the front polygons automatically the front, the front polygons automatically hide the polygons further back.hide the polygons further back.

Since the data is well-structured, this is Since the data is well-structured, this is possible.possible.

If hidden surface removal is done in software, If hidden surface removal is done in software, this might be faster than turning on z-this might be faster than turning on z-buffering.buffering.

Page 14: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 14Chapter 12 -- Visualization

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

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

Page 15: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 15Chapter 12 -- Visualization

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

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

Page 16: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 16Chapter 12 -- Visualization

The basic mesh plot can be extended in The basic mesh plot can be extended in many ways.many 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 required normals can be computed from the vertices of the triangles or quadrilaterals.the 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 The texture map might be an image of the

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

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

Page 17: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 17Chapter 12 -- Visualization

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 although they give a visual impression of the data, it is difficult to make measurements data, it is difficult to make measurements from them. from them.

An alternative method of displaying the height An alternative method of displaying the height data is to display contours -- curves that data is to display contours -- curves that correspond to a fixed value of height.correspond to 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/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 18Chapter 12 -- Visualization

2.3 Marching Squares2.3 Marching Squares Suppose:Suppose:

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

that we would like to find an that we would like to find an approximate contour curveapproximate contour curve

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

We start with a rectangular cell We start with a rectangular cell determined by four grid pointsdetermined by four grid points

Page 19: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 19Chapter 12 -- Visualization

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

Consider this caseConsider this case

Page 20: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 20Chapter 12 -- Visualization

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

The principle to consider is:The principle to consider is: When there are multiple possible When there are multiple possible

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

Page 21: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 21Chapter 12 -- Visualization

Returning to our example:Returning to our example: We can now draw the line for this cell. We can now draw the line for this cell.

The issue is where do we draw it?The issue is where do we draw it? Pick the mid point on each edge and connect Pick the mid point on each edge and connect

themthem Interpolate the crossing points.Interpolate the crossing points.

There are 16 (2There are 16 (244)ways that we can )ways that we can color the vertices of a cell using only color the vertices of a cell using only black and white.black and white. All could arise in our contour problem.All could arise in our contour problem. These cases are itemized on the next These cases are itemized on the next

slideslide

Page 22: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 22Chapter 12 -- Visualization

Page 23: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 23Chapter 12 -- Visualization

If we study these cases, we see that If we study these cases, we see that there are two types of symmetrythere are two types of symmetry Rotational (1 & 2)Rotational (1 & 2) Inverses (0 & 15)Inverses (0 & 15)

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

Page 24: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 24Chapter 12 -- Visualization

The first case has no lineThe first case has no line The second case is what we just The second case is what we just

discussed.discussed. The third case has a line from side to The third case has a line from side to

sideside The fourth case is ambiguous since there The fourth case is ambiguous since there

are two equally valid interpretationsare two equally valid interpretations

Page 25: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 25Chapter 12 -- Visualization

We have no reason to prefer one over the We have no reason to prefer one over the otherother

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 But as this figure shows, we get different results depending upon the interpretation we results depending upon the interpretation we choosechoose

Page 26: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 26Chapter 12 -- Visualization

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

Page 27: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 27Chapter 12 -- Visualization

We then can assign the cell to one of the We then can assign the cell to one of the four cases by: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 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/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 28Chapter 12 -- Visualization

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 // compute the lower left corner of the cell and s_x and s_y

here.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/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 29Chapter 12 -- Visualization

The following figure shows two The following figure shows two curves corresponding to a single curves corresponding to a single contour value for:contour value for: f(x,y) = (xf(x,y) = (x22+y+y22+a+a22))22-4a-4a22xx22-b-b44 (with (with

a=0.49, b=0.5)a=0.49, b=0.5)

The function was sampled on a 50x50 The function was sampled on a 50x50 gridgrid

The left uses midpoint, the right The left uses midpoint, the right interpolation.interpolation.

Page 30: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 30Chapter 12 -- Visualization

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

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

Page 31: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 31Chapter 12 -- Visualization

3. Visualizing Surfaces 3. Visualizing Surfaces and Scalar Fieldsand Scalar Fields

The surface and contour problems just The surface and contour problems just described have three-dimensional described have three-dimensional extensions.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 An example is the density inside an object

or the absorption of X-rays in the human or the absorption of X-rays in the human body.body.

Page 32: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 32Chapter 12 -- Visualization

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

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

Consequently, operations that are routine Consequently, operations that are routine for 2D data (reading files and performing for 2D data (reading files and performing transformations) present practical transformations) present practical difficulties.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 independent variables, we were able to use the third dimension to visualize scalars. third 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 Nevertheless, if we are careful, we can extend our previously developed methods to visualize our previously developed methods to visualize three-dimensional scalar fieldsthree-dimensional scalar fields

Page 33: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 33Chapter 12 -- Visualization

3.1 Volumetric Data Sets3.1 Volumetric Data Sets Once again, assume that our samples Once again, assume that our samples

are taken at equally spaced points in are taken at equally spaced points in x,y, and zx,y, and z

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

Page 34: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 34Chapter 12 -- Visualization

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

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

makes use of every voxel in producing an makes use of every voxel in producing an imageimage

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

Page 35: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 35Chapter 12 -- Visualization

3.2 Visualization of Implicit 3.2 Visualization of Implicit FunctionsFunctions This is the natural extension of This is the natural extension of

contours to 3Dcontours to 3D

Consider the implicit function in Consider the implicit function in three dimensionsthree dimensions g(x,y,z) = 0 where g is known g(x,y,z) = 0 where g is known

analytically.analytically. One way to attack this problem involves One way to attack this problem involves

a simple form of ray tracing (ray casting)a simple form of ray tracing (ray casting)

Page 36: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 36Chapter 12 -- Visualization

Finding isosurfaces usually involves Finding isosurfaces usually involves working with a discretized version of working with a discretized version of the problemthe problem replacing g by a set of samples taken replacing g by a set of samples taken

over some grid.over some grid.

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

Page 37: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 37Chapter 12 -- Visualization

4. Isosurfaces and 4. Isosurfaces and Marching CubesMarching Cubes

Assume that we have a data set, where Assume that we have a data set, where each voxel is a sample of the scalar field each voxel is a sample of the scalar field f(x,y,z)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/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 38Chapter 12 -- Visualization

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

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

Page 39: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 39Chapter 12 -- Visualization

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

Finally we can use the triangle Finally we can use the triangle polygons to tessellate these polygons to tessellate these intersections.intersections.

Page 40: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 40Chapter 12 -- Visualization

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

There is an ambiguity problem There is an ambiguity problem analogous to the one for contour analogous to the one for contour mapsmaps

Page 41: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 41Chapter 12 -- Visualization

5. Mesh Simplification5. Mesh Simplification

On disadvantage of marching cubes is On disadvantage of marching cubes is that the algorithm can generate many that the algorithm can generate many more triangles than are really needed to more triangles than are really needed to display the isosurface.display the isosurface. One reason can be the resolution of the data One reason can be the resolution of the data

set.set. We can often create a new mesh with far We can often create a new mesh with far

fewer triangles such that the rendered fewer triangles such that the rendered surfaces are visually indistinguishable.surfaces are visually indistinguishable.

There are multiple approaches to this mesh There are multiple approaches to this mesh simplification problemsimplification problem

Page 42: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 42Chapter 12 -- Visualization

One popular approach is triangle One popular approach is triangle decimation.decimation. It seeks to simplify the mesh by removing It seeks to simplify the mesh by removing

some edges and vertices.some edges and vertices. Example:Example:

The decision as to which triangles are to be The decision as to which triangles are to be removed can be made using criteria such as removed can be made using criteria such as the local smoothness or the shape of the the local smoothness or the shape of the trianglestriangles

The latter is important since long thin triangles do The latter is important since long thin triangles do not render wellnot render well

Page 43: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 43Chapter 12 -- Visualization

Other approaches are based upon Other approaches are based upon resampling the surface generated resampling the surface generated by the original mesh , thus creating by the original mesh , thus creating a new surfacea new surface

Probably the most popular Probably the most popular technique is Delauney technique is Delauney triangulation.triangulation. This algorithm creates a triangular This algorithm creates a triangular

mesh in which the circle determined mesh in which the circle determined by the vertices of each triangle by the vertices of each triangle contains no other vertices.contains no other vertices.

The complexity of this is O(n log n)The complexity of this is O(n log n)

Page 44: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 44Chapter 12 -- Visualization

6. Direct Volume 6. Direct Volume RenderingRendering

The weakness of isosurface rendering is The weakness of isosurface rendering is that not all voxels contribute to the final that not all voxels contribute to the final image.image. Consequently, we could miss the most Consequently, we could miss the most

important part of the data by selecting the important part of the data by selecting the wrong isovalue.wrong isovalue.

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

Page 45: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 45Chapter 12 -- Visualization

Early methods for direct volume Early methods for direct volume rendering treated each voxel as a rendering treated each voxel as a small cube that was either small cube that was either transparent or completely opaque.transparent or completely opaque. These techniques produced images with These techniques produced images with

serious aliasing artifacts.serious aliasing artifacts.

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

Page 46: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 46Chapter 12 -- Visualization

6.1 Assignment of Color and 6.1 Assignment of Color and OpacityOpacity We start by assigning a color and We start by assigning a color and

transparency to each voxel.transparency to each voxel. If the data are from a computer-If the data are from a computer-

tomography scan of a person’s head, we tomography scan of a person’s head, we might assign colors based upon the X-ray might assign colors based upon the X-ray density.density.

Soft tissues (low density) might be red.Soft tissues (low density) might be red. Fatty tissues (medium densities) might be Fatty tissues (medium densities) might be

blueblue Hard tissues (high densities) might be whiteHard tissues (high densities) might be white Empty space might be black.Empty space might be black.

Page 47: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 47Chapter 12 -- Visualization

Often, these color assignments are Often, these color assignments are based upon the voxel distributionbased upon the voxel distribution Here is an example histogramHere is an example histogram

Page 48: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 48Chapter 12 -- Visualization

6.2 Splatting6.2 Splatting Once colors and opacities are Once colors and opacities are

assigned,, we can assign a geometric assigned,, we can assign a geometric shape to each object.shape to each object. Sometimes this is done with a back to Sometimes this is done with a back to

front painting.front painting. Consider the voxels in the following figure Consider the voxels in the following figure

Page 49: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 49Chapter 12 -- Visualization

Each voxel is assigned a simple shape Each voxel is assigned a simple shape and this shape is projected onto the and this shape is projected onto the image plane. This projected footprint image plane. This projected footprint is also known as a splat.is also known as a splat.

Color plate 28 is an example of thisColor plate 28 is an example of this

Page 50: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 50Chapter 12 -- Visualization

6.3 Volume Ray Tracing6.3 Volume Ray Tracing An alternative direct-volume An alternative direct-volume

rendering technique is front-to-back rendering technique is front-to-back rendering by raytracing.rendering by raytracing.

Page 51: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 51Chapter 12 -- Visualization

6.4 Texture Mapping of Volumes6.4 Texture Mapping of Volumes The importance of texture mapping The importance of texture mapping

in animation systems has led to the in animation systems has led to the inclusion of large amounts of texture inclusion of large amounts of texture memory in recent graphics systems. memory in recent graphics systems. Once texture mapping is supported by Once texture mapping is supported by

the hardware, we can render scenes with the hardware, we can render scenes with texture mapping at almost the same rate texture mapping at almost the same rate as we can scenes without texture.as we can scenes without texture.

Three-dimensional texture rendering Three-dimensional texture rendering (which OpenGL supports) suggest a new (which OpenGL supports) suggest a new approach to direct volume rendering.approach to direct volume rendering.

Page 52: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 52Chapter 12 -- Visualization

7. Vector Field 7. Vector Field VisualizationVisualization

Our first visualization task considered a scalar Our first visualization task considered a scalar field f(x,y,z) defined over a volume of space. field 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 measure not a single value but rather a vector of n values.of n 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-Our visualization techniques for three-dimensional vector fields employ two primary dimensional vector fields employ two primary tools:tools:

color and geometric objects.color and geometric objects.

Page 53: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 53Chapter 12 -- Visualization

7.1 Hedgehogs7.1 Hedgehogs Example: Blood flow visualizationExample: Blood flow visualization

Page 54: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 54Chapter 12 -- Visualization

7.2 Glyphs7.2 Glyphs Example: flow visualizationExample: flow visualization

Page 55: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 55Chapter 12 -- Visualization

7.3 Color7.3 Color Sometimes called color quantizationSometimes called color quantization

Selection of a color for an intensitySelection of a color for an intensity

Page 56: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 56Chapter 12 -- Visualization

7.4 Particle Traces and 7.4 Particle Traces and StreamlinesStreamlines Typically used if computational fluid Typically used if computational fluid

dynamicsdynamics

Page 57: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 57Chapter 12 -- Visualization

8. Tensor Visualization8. Tensor Visualization

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

For example, we might measure stress For example, we might measure stress or strain at every point within a solid or strain at every point within a solid material that is subject to external material that is subject to external forces.forces. The stress at a point (x,y,z) in the material The stress at a point (x,y,z) in the material

can be described by a 3x3 matrixcan be described by a 3x3 matrix

Page 58: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 58Chapter 12 -- Visualization

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

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

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

the eigenvalues are the most important the eigenvalues are the most important characteristic of a matrix. characteristic 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 the eigenvalues determine the length of the three axes of the ellipsethree axes of the ellipse

the eigenvectors determine the orientationthe eigenvectors determine the orientation

Page 59: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 59Chapter 12 -- Visualization

9. Summary9. Summary

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

can they burden the best of hardware, but can they burden the best of hardware, but also conceptually simple operations also conceptually simple operations (rendering, repositioning data) can be (rendering, repositioning data) can be difficult.difficult.

Page 60: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 60Chapter 12 -- Visualization

For volumetric data sets of scalars, we For volumetric data sets of scalars, we have introduced two general approaches: have introduced two general approaches: isosurfaces and volume rendering.isosurfaces and volume rendering. These techniques are fast and construct These techniques are fast and construct

geometric objects that can be manipulated geometric objects that can be manipulated interactively.interactively.

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

Vector-visualization techniques are most Vector-visualization techniques are most important in flow visualizationimportant in flow visualization Here we have sought to show patterns of Here we have sought to show patterns of

flow through a variety of techniques flow through a variety of techniques including hedgehogs, glyphs, streamlines, including hedgehogs, glyphs, streamlines, and particle traces.and particle traces.

Page 61: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 61Chapter 12 -- Visualization

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

The difficulties are twofoldThe difficulties are twofold First, our graphics systems can display First, our graphics systems can display

only three-dimensional primitives.only three-dimensional primitives. Second, although we can use other Second, although we can use other

variables, such as color, to increase the variables, such as color, to increase the “dimension” of the display, human “dimension” of the display, human observers may have difficulty observers may have difficulty interpreting such displaysinterpreting such displays

Page 62: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 62Chapter 12 -- Visualization

10. Suggested Readings10. Suggested Readings

The marching-squares method is a special The marching-squares method is a special case of the marching cubes method case of the marching cubes method popularized by Lorenson and Kline (87)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 Early attempts to visualize volumes were reported by Herman (79) and by Fuchs (77)reported 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 63: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 63Chapter 12 -- Visualization

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

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

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

Page 64: Visualization Chapter 12. CS 480/680 2Chapter 12 -- Visualization Introduction: Introduction: In this chapter, we apply almost everything we have done

CS 480/680 64Chapter 12 -- Visualization

Exercises -- Due next Exercises -- Due next classclass