env 200612.1 envisioning information lecture 12 – scientific visualization scalar 2d data ken...

40
ENV 2006 12.1 Envisioning Information Lecture 12 – Scientific Visualization Scalar 2D Data Ken Brodlie [email protected]

Upload: amia-cochran

Post on 28-Mar-2015

217 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: ENV 200612.1 Envisioning Information Lecture 12 – Scientific Visualization Scalar 2D Data Ken Brodlie kwb@comp.leeds.ac.uk

ENV 2006 12.1

Envisioning Information

Lecture 12 – Scientific Visualization

Scalar 2D Data

Ken [email protected]

Page 2: ENV 200612.1 Envisioning Information Lecture 12 – Scientific Visualization Scalar 2D Data Ken Brodlie kwb@comp.leeds.ac.uk

ENV 2006 12.2

2D Interpolation – Regular Gridded Data

• Suppose we are given data on a regular rectangular grid

f given at eachgrid point; wefill out the emptyspaces byinterpolating valueswithin each cell

Page 3: ENV 200612.1 Envisioning Information Lecture 12 – Scientific Visualization Scalar 2D Data Ken Brodlie kwb@comp.leeds.ac.uk

ENV 2006 12.3

• Straightforward extension from 1D: take f-value from nearest data sample

• No continuity• Bounds fixed at data extremes

Nearest Neighbour Interpolation

Page 4: ENV 200612.1 Envisioning Information Lecture 12 – Scientific Visualization Scalar 2D Data Ken Brodlie kwb@comp.leeds.ac.uk

ENV 2006 12.4

• Consider one grid rectangle:– suppose corners are at (0,0), (1,0), (1,1), (0,1) ... ie a unit square

– values at corners are f00, f10, f11, f01

f00 f10

f01 f11

How do weestimate valueat a point (x,y)inside thesquare?

Bilinear Interpolation

Page 5: ENV 200612.1 Envisioning Information Lecture 12 – Scientific Visualization Scalar 2D Data Ken Brodlie kwb@comp.leeds.ac.uk

ENV 2006 12.5

f00 f10

f01 f11

(i) interpolate in x-direction between f00,f10; and f01,f11

(ii) interpolate in y-direction

We carry out three 1D interpolations:

Exercise: Show this is equivalent to calculatingf(x,y) = (1-x)(1-y)f00+x(1-y)f10+(1-x)yf01+ xyf11

(x,y)

Bilinear Interpolation

Page 6: ENV 200612.1 Envisioning Information Lecture 12 – Scientific Visualization Scalar 2D Data Ken Brodlie kwb@comp.leeds.ac.uk

ENV 2006 12.6

• Apply within each grid rectangle• Fast• Continuity of value, not slope (C0)• Bounds fixed at data extremes

Piecewise Bilinear Interpolation

Page 7: ENV 200612.1 Envisioning Information Lecture 12 – Scientific Visualization Scalar 2D Data Ken Brodlie kwb@comp.leeds.ac.uk

ENV 2006 12.7

Contour Drawing

• Contouring is very common technique for 2D scalar data

• Isolines join points of equal value

– sometimes with shading added

• How can we quickly and accurately draw these isolines?

Page 8: ENV 200612.1 Envisioning Information Lecture 12 – Scientific Visualization Scalar 2D Data Ken Brodlie kwb@comp.leeds.ac.uk

ENV 2006 12.8

• As an example, consider this data:

10 -5

1 -2

Where does the zero level contour go?

An Example

Page 9: ENV 200612.1 Envisioning Information Lecture 12 – Scientific Visualization Scalar 2D Data Ken Brodlie kwb@comp.leeds.ac.uk

ENV 2006 12.9

• The bilinear interpolant is linear along any edge - thus we can predict where the contour will cut the edges (just by simple proportions)

10 -5

-21

10

-5

cross-section viewalong top edge

Intersections with sides

Page 10: ENV 200612.1 Envisioning Information Lecture 12 – Scientific Visualization Scalar 2D Data Ken Brodlie kwb@comp.leeds.ac.uk

ENV 2006 12.10

Simple Approach

• A simple approach to get the contour inside the grid rectangle is just to join up the intersection points

10 -5

-21

Question:Does this always work?

Try an example whereone pair of oppositecorners are positive,other pair negative

Page 11: ENV 200612.1 Envisioning Information Lecture 12 – Scientific Visualization Scalar 2D Data Ken Brodlie kwb@comp.leeds.ac.uk

ENV 2006 12.11

• But this does not always work - look at this data:

10 -5

1-3

Try it - it is ambiguous!

Ambiguity

Page 12: ENV 200612.1 Envisioning Information Lecture 12 – Scientific Visualization Scalar 2D Data Ken Brodlie kwb@comp.leeds.ac.uk

ENV 2006 12.12

• We need to worry about the behaviour of the interpolant inside the grid square

• The contour of the bilinear interpolant is NOT a straight line – it is a curve -

10 -5

-21

This is curve of: f(x,y) = (1-x)(1-y)f00+x(1-y)f10+(1-x)yf01+ xyf11

= 0

BUT how can we draw it?

Joining intersectionswith straight lineswas only an approximation…drawing the contourof bilinear interpolantwill resolve ambiguity

What is the Problem?

Page 13: ENV 200612.1 Envisioning Information Lecture 12 – Scientific Visualization Scalar 2D Data Ken Brodlie kwb@comp.leeds.ac.uk

ENV 2006 12.13

Tracking Contours

• We can track the contour in small steps through the grid rectangle – starting from intersection with the edges– Take a step, probe at equal distance to either side, then predict

next point

Next point oncontour

-0.3

0.9

Current pointon contour

Probes

-0.3

0.9

BUT THIS IS SLOW!!

Can we find an alternative which uses straight lines, but resolves the ambiguous case?

Page 14: ENV 200612.1 Envisioning Information Lecture 12 – Scientific Visualization Scalar 2D Data Ken Brodlie kwb@comp.leeds.ac.uk

ENV 2006 12.14

Implementing Rectangle-based Contouring

• For a rectangle, there will be 24 = 16 cases

• There are 4 configurations– All same sign (no contour)– 3 same sign (one contour

piece)– 2 adjacent with same sign (one

contour piece)– 2 opposite with same sign (two

pieces, but ambiguous… function has a saddle)

+ +

+ +

+ +

+ -

+ -

+ -

+ -

- +

Note: the ambiguity can be resolvedby looking at value at saddle point:

Saddle value = (f00f11 - f01f10)/ (f00+f11-f01+f10)

Page 15: ENV 200612.1 Envisioning Information Lecture 12 – Scientific Visualization Scalar 2D Data Ken Brodlie kwb@comp.leeds.ac.uk

ENV 2006 12.15

Solution by Decomposing Cell

• Another possibility is to split cell into four triangles

• Within a triangle, we can fit a linear model

– F(x,y) = a + bx +cy

• How do we split?• How do we calculate a,b,c?• What is the gain?

f1

f2 f3

Page 16: ENV 200612.1 Envisioning Information Lecture 12 – Scientific Visualization Scalar 2D Data Ken Brodlie kwb@comp.leeds.ac.uk

ENV 2006 12.16

Cell Decomposition

• Problem of drawing the curved lines has been circumvented by decomposing cell into four pieces within which the contours are well defined straight lines

• How might we estimate value at centre?

10 -5

-3 1

0.75

Page 17: ENV 200612.1 Envisioning Information Lecture 12 – Scientific Visualization Scalar 2D Data Ken Brodlie kwb@comp.leeds.ac.uk

ENV 2006 12.17

Contouring in IRIS Explorer

• Contour is a simple contouring module

• NAGContour interpolates the data and then tracks the contours

NAGContour

Page 18: ENV 200612.1 Envisioning Information Lecture 12 – Scientific Visualization Scalar 2D Data Ken Brodlie kwb@comp.leeds.ac.uk

ENV 2006 12.18

• Often the data will be given, not on a regular grid, but at scattered locations:

f given at eachmarked point

Approach:(i) triangulate(ii) build interpolantin each triangle(iii) draw contours

2D Interpolation – Scattered Data

Page 19: ENV 200612.1 Envisioning Information Lecture 12 – Scientific Visualization Scalar 2D Data Ken Brodlie kwb@comp.leeds.ac.uk

ENV 2006 12.19

• Triangulation is the process of forming a grid of triangles from the data points

How can we construct the triangulation?

Triangulation

Page 20: ENV 200612.1 Envisioning Information Lecture 12 – Scientific Visualization Scalar 2D Data Ken Brodlie kwb@comp.leeds.ac.uk

ENV 2006 12.20

• We solve the DUAL problem:– Suppose a wolf is stationed at each data point. Each wolf is equally

powerful and dominates the territory closest to its own base

– What are the territories dominated by each wolf?

Tesselation

Page 21: ENV 200612.1 Envisioning Information Lecture 12 – Scientific Visualization Scalar 2D Data Ken Brodlie kwb@comp.leeds.ac.uk

ENV 2006 12.21

Tesselation – Two or three wolves

Page 22: ENV 200612.1 Envisioning Information Lecture 12 – Scientific Visualization Scalar 2D Data Ken Brodlie kwb@comp.leeds.ac.uk

ENV 2006 12.22

Tesselation - Two or Three Wolves

Page 23: ENV 200612.1 Envisioning Information Lecture 12 – Scientific Visualization Scalar 2D Data Ken Brodlie kwb@comp.leeds.ac.uk

ENV 2006 12.23

• The resulting tesselation is known as the Dirichlet or Voronoi tesselation

• Given the Dirichlet tesselation for N points

P1, P2, ... PN

there is an algorithm for constructing the tesselation when an extra point is added

Dirichlet Tesselation

Page 24: ENV 200612.1 Envisioning Information Lecture 12 – Scientific Visualization Scalar 2D Data Ken Brodlie kwb@comp.leeds.ac.uk

ENV 2006 12.24

P1

P2

P3

Tesselation forP1, P2, P3

QPoint Qadded

Dirichlet Tesselation

Page 25: ENV 200612.1 Envisioning Information Lecture 12 – Scientific Visualization Scalar 2D Data Ken Brodlie kwb@comp.leeds.ac.uk

ENV 2006 12.25

P1

P2

P3

Q

Dirichlet Tesselation

Page 26: ENV 200612.1 Envisioning Information Lecture 12 – Scientific Visualization Scalar 2D Data Ken Brodlie kwb@comp.leeds.ac.uk

ENV 2006 12.26

P1

P2

P3

Q

Dirichlet Tesselation

Page 27: ENV 200612.1 Envisioning Information Lecture 12 – Scientific Visualization Scalar 2D Data Ken Brodlie kwb@comp.leeds.ac.uk

ENV 2006 12.27

– Determine polygon containing Q - here D3, surrounding P3

– Construct perpendicular bisector of P3Q and find intersection with D3 - this becomes point of modified tesselation

– Determine adjacent polygon - here D2

– Repeat the above two steps until D3 is reached again, or there is no intersection

– Remove all vertices and edges interior to the new polygon

Dirichlet Tesselation

Page 28: ENV 200612.1 Envisioning Information Lecture 12 – Scientific Visualization Scalar 2D Data Ken Brodlie kwb@comp.leeds.ac.uk

ENV 2006 12.28

P1

P2

P3

Q

Delaunay Triangulation

Page 29: ENV 200612.1 Envisioning Information Lecture 12 – Scientific Visualization Scalar 2D Data Ken Brodlie kwb@comp.leeds.ac.uk

ENV 2006 12.29

• Triangulation formed by joining points whose ‘territories’ share a common boundary in the tesselation

• This has the nice property that it avoids long skinny triangles• See the nice applets at:

www.cs.cornell.edu/Info/People/chew/ Delaunay.html

• Note the ‘empty circle’ property of the Delaunay triangulation

Delaunay Triangulation

Page 30: ENV 200612.1 Envisioning Information Lecture 12 – Scientific Visualization Scalar 2D Data Ken Brodlie kwb@comp.leeds.ac.uk

ENV 2006 12.30

Contouring from Triangulated Data

• The final step is to contour from the triangulated data

• Easy – because contours of linear interpolant are straight lines – see earlier

http://www.tecplot.com

Page 31: ENV 200612.1 Envisioning Information Lecture 12 – Scientific Visualization Scalar 2D Data Ken Brodlie kwb@comp.leeds.ac.uk

ENV 2006 12.31

Implementing Triangle-based Contouring

• Each vertex can be positive or negative (ignore zero for now)

• This gives 23 = 8 possible cases…

• … but there are only 2 distinct configurations– No contour (all same sign)– Contour (2 of one sign, 1

of the other) • Implementation:

– Determine which of 8 cases

– Select code for the appropriate configuration

f1

f2 f3

f1

f2 f3

All same sign

Two same sign

In IRIS Explorer, NAGContour will contour scattered data – using triangulation followed by a tracking method based on a nonlinear interpolant – for greater accuracy

Page 32: ENV 200612.1 Envisioning Information Lecture 12 – Scientific Visualization Scalar 2D Data Ken Brodlie kwb@comp.leeds.ac.uk

ENV 2006 12.32

• A different mapping technique for 2D scalar data is the surface view.

• Here a surface is created in 3D space, the height representing the scalar value

• Construction is quite easy - suppose we have a rectangular grid

Surface Views

Page 33: ENV 200612.1 Envisioning Information Lecture 12 – Scientific Visualization Scalar 2D Data Ken Brodlie kwb@comp.leeds.ac.uk

ENV 2006 12.33

Constructing a Surface View - 1

Page 34: ENV 200612.1 Envisioning Information Lecture 12 – Scientific Visualization Scalar 2D Data Ken Brodlie kwb@comp.leeds.ac.uk

ENV 2006 12.34

Surface created as pair of triangles per grid rectangle.Rendering step is then display of triangles.

Constructing a Surface View - 2

Page 35: ENV 200612.1 Envisioning Information Lecture 12 – Scientific Visualization Scalar 2D Data Ken Brodlie kwb@comp.leeds.ac.uk

ENV 2006 12.35

Examples - with added contours

www.tecplot.com

Page 36: ENV 200612.1 Envisioning Information Lecture 12 – Scientific Visualization Scalar 2D Data Ken Brodlie kwb@comp.leeds.ac.uk

ENV 2006 12.36

• A further mapping technique for 2D data is the image plot• There are three variants:

– dot array : draw a dot at each data point, coloured according to the value (very fast, but low quality)

Image Plots

Page 37: ENV 200612.1 Envisioning Information Lecture 12 – Scientific Visualization Scalar 2D Data Ken Brodlie kwb@comp.leeds.ac.uk

ENV 2006 12.37

Image Plots

Grid lines:

Page 38: ENV 200612.1 Envisioning Information Lecture 12 – Scientific Visualization Scalar 2D Data Ken Brodlie kwb@comp.leeds.ac.uk

ENV 2006 12.38

Image Plots

Areas:

Page 39: ENV 200612.1 Envisioning Information Lecture 12 – Scientific Visualization Scalar 2D Data Ken Brodlie kwb@comp.leeds.ac.uk

ENV 2006 12.39

IRIS Explorer – Image Plots and Surface Views

• Image views are created using:– LatToGeom: takes a lattice

(array of values) and produces a colour mosaic

– GenerateColorMap: associates colours with values

• Surface views are created using:

– DisplaceLat: takes two lattices, one to create the surface (displacement), the other to colour it (function)… and builds a 3D lattice

– LatToGeom: converts this 3D lattice to geometry

Page 40: ENV 200612.1 Envisioning Information Lecture 12 – Scientific Visualization Scalar 2D Data Ken Brodlie kwb@comp.leeds.ac.uk

ENV 2006 12.40

Module Assessment

• Research topic (50)

• Portfolio to include:– November draft submission – Review comments– Response to comments– Final paper (35)– Presentation (15)

• Practical exam (50)– One exercise using xmdvtool

(25)– One exercise using IRIS

Explorer (25)– Task will be to explore a

dataset in each case– 2 hour supervised exam in

laboratory