Presentation on theme: "Visualization Techniques -"— Presentation transcript:
1 Visualization Techniques - Data VisualizationLecture 3Visualization Techniques -1D Scalar Data2D Scalar Data (part 1)
2 Visualization Techniques - One Dimensional Scalar Data
3 1D Interpolation -The Problem f43211.751234xGiven (x1,f1), (x2,f2), (x3,f3), (x4,f4) - estimate the value off at other values of x - say, x*. Suppose x*=1.75
4 Nearest Neighbourf431.75211234xTake f-value at x* as f-value of nearest data sample.So if x* = 1.75, then f estimated as 3
5 Linear Interpolation f x 431.752.5211234xJoin data points with straight lines- read offf-value corresponding to x*.. in the case thatx*=1.75, then f estimated as 2.5
6 Linear Interpolation - Doing the Calculation Suppose x* lies between x1 and x2. Then apply thetransformation:t = (x*-x1)/(x2-x1)so that t goes from 0 to 1.t=(1.75-1)/(2-1)=0.75f(x*) = (1-t) f1 + t f2The functions j(t)=1-t and k(t)=t are basis functions.OR, saving a multiplication:f(x*) = f1 + t ( f2 - f1 )f(1.75)=0.25*1+0.75*3=2.5f(1.75)=1+0.75*(3-1)=2.5
7 Nearest Neighbour and Linear Interpolation Very fast : no arithmetic involvedContinuity : discontinuous valueBounds : bounds fixed at data extremesLinear InterpolationFast : one multiply, one divideContinuity : value only continuous, not slope (C0)
8 Drawing a Smooth CurveRather than straight line between points, we create a curve piecex1x2f1f2We estimate theslopes g1 and g2at the data points,and construct curvewhich has these valuesand these slopes atend-pointsg1g2
9 Slope EstimationSlopes estimated as some average of the slopes of adjacent chords - eg to estimate slope at x2g2g2 usuallyarithmetic mean(ie average) of = (f2-f1)/(x2-x1)f2f1f3x1x2x3
10 Piecewise Cubic Interpolation Once the slopes at x1 and x2 are known, thisis sufficient to define a unique cubic polynomialin the interval [x1,x2]f(x) = c1(x) * f1+ c2(x) * f2+ h*(d1(x) * g1- d2(x) * g2)g1f1g2ci(x), di(x) arecubic Hermitebasis functions,h = x2 – x1.f2x1x2
11 Cubic Hermite Basis Functions Here they are:Again set t = (x - x1)/(x2 – x1)c1 (t) = 3(1-t)2 - 2(1-t)3c2 (t) = 3t2 - 2t3d1 (t) = (1-t)2 - (1-t)3d2 (t) = t2 - t3Check the valuesat x = x1, x2 (ie t=0,1)
13 Piecewise Cubic Interpolation More computation needed than with nearest neighbour or linear interpolation.Continuity: slope continuity (C1) by construction - and cubic splines will give second derivative continuity (C2)Bounds: bounds not controlled generally - eg if arithmetic mean used in slope estimation...
14 Shape ControlHowever special choices for slope estimation do give control over shapeIf the harmonic mean is used1/g2 = 0.5 ( 1/1 + 1/2)then we find that f(x) lies within the bounds of the data
15 Coal data – keeping within the bounds of the data
16 Rendering Line Graphs The final rendering step is straightforward We can assume that the underlying graphics system will be able to draw straight line segmentsThus the linear interpolation case is trivialFor curves, we do an approximation as sequence of small line segments
17 Background Study Take the coal furnace data from lecture 2 Investigate how to present this as a graph in Excel (not easy!)After learning gnuplot in the practical class, create a graph of the coal data using gnuplotLook for Java applets on the Web that will create line graphs
18 Visualization Techniques Two Dimensional Scalar Data
19 2D Interpolation - Rectangular Grid Suppose we are given data on rectangular grid:f given at eachgrid point;data enrichmentfills out the emptyspaces byinterpolating valueswithin each cell
20 Nearest Neighbour Interpolation Straightforward extension from 1D: take f-value from nearest data sampleNo continuityBounds fixed at data extremes
21 Bilinear Interpolation Consider one grid rectangle:suppose corners are at (0,0), (1,0), (1,1), (0,1) ... ie a unit squarevalues at corners are f00, f10, f11, f01f00f10f01f11How do weestimate valueat a point (x,y)inside thesquare?
22 Bilinear Interpolation f00f10f01f11(x,y)(i) interpolate in x-direction between f00,f10; and f01,f11(ii) interpolate in y-directionWe carry out three 1D interpolations:Exercise: Show this is equivalent to calculating -f(x,y) = (1-x)(1-y)f00+x(1-y)f10+(1-x)yf01+ xyf11
23 Piecewise Bilinear Interpolation Apply within each grid rectangleFastContinuity of value, not slope (C0)Bounds fixed at data extremes
24 Contour Drawing Contouring is very common technique for 2D scalar data Isolines join points of equal valuesometimes with shading addedHow can we quickly and accurately draw these isolines?
25 An Example As an example, consider this data: -5 10 1 -2 Where does the zero level contour go?
26 Intersections with sides The bilinear interpolant is linear along any edge - thus we can predict where the contour will cut the edges (just by simple proportions)10-5cross-section viewalong top edge10-5-21
27 Simple ApproachA simple approach to get the contour inside the grid rectangle is just to join up the intersection pointsQuestion:Does this always work?Try an example whereone pair of oppositecorners are positive,other pair negative10-5-21