Interpolation, color, & light. Outline Announcements –HW II--due today, 5PM –HW III on the web later today HW I: Issues Structured vs. Unstructured Meshes.

Slides:



Advertisements
Similar presentations
Efficient access to TIN Regular square grid TIN Efficient access to TIN Let q := (x, y) be a point. We want to estimate an elevation at a point q: 1. should.
Advertisements

CS 376b Introduction to Computer Vision 04 / 21 / 2008 Instructor: Michael Eckmann.
Chapter 11 Above: Principal contraction rates calculated from GPS velocities. Visualized using MATLAB.
SE 313 – Computer Graphics Lecture 13: Lighting and Materials Practice Lecturer: Gazihan Alankuş 1.
Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 51 Today’s class Geometric objects and transformations.
University of Wisconsin-Milwaukee Geographic Information Science Geography 625 Intermediate Geographic Information Science Instructor: Changshan Wu Department.
3D and Surface/Terrain Analysis
HCI 530 : Seminar (HCI) Damian Schofield.
By Hrishikesh Gadre Session II Department of Mechanical Engineering Louisiana State University Engineering Equation Solver Tutorials.
Announcements Final Exam May 16 th, 8 am (not my idea). Practice quiz handout 5/8. Review session: think about good times. PS5: For challenge problems,
Raster Data. The Raster Data Model The Raster Data Model is used to model spatial phenomena that vary continuously over a surface and that do not have.
Modelling. Outline  Modelling methods  Editing models – adding detail  Polygonal models  Representing curves  Patched surfaces.
X86 and 3D graphics. Quick Intro to 3D Graphics Glossary: –Vertex – point in 3D space –Triangle – 3 connected vertices –Object – list of triangles that.
Introduction to Volume Visualization Mengxia Zhu Fall 2007.
Now Playing: My Mathematical Mind Spoon From Gimme Fiction Released May 10, 2005.
University of British Columbia CPSC 414 Computer Graphics © Tamara Munzner 1 Shading Week 5, Wed 1 Oct 2003 recap: lighting shading.
Lecture 07: Terrain Analysis Geography 128 Analytical and Computer Cartography Spring 2007 Department of Geography University of California, Santa Barbara.
Applications in GIS (Kriging Interpolation)
Computer Graphics Inf4/MSc Computer Graphics Lecture 11 Texture Mapping.
Slope and Aspect Calculated from a grid of elevations (a digital elevation model) Slope and aspect are calculated at each point in the grid, by comparing.
SET09115 Intro Graphics Programming
Terrain Mapping and Analysis
CS 445 / 645: Introductory Computer Graphics
 1999 BG Mobasseri1 8/29/2015 MATLAB GRAPHICS - PART II ADVANCED PLOTTING June 4, ‘99.
1 Computer Graphics Week13 –Shading Models. Shading Models Flat Shading Model: In this technique, each surface is assumed to have one normal vector (usually.
Polygon Shading. Assigning color to a shape to make graphical scenes look realistic, or artistic, or whatever effect we’re attempting to achieve But first.
CS 450: Computer Graphics REVIEW: OVERVIEW OF POLYGONS
Technology and Historical Overview. Introduction to 3d Computer Graphics  3D computer graphics is the science, study, and method of projecting a mathematical.
Computer Graphics World, View and Projection Matrices CO2409 Computer Graphics Week 8.
Week 11 - Thursday.  What did we talk about last time?  Image processing  Blurring  Edge detection  Color correction  Tone mapping  Lens flare.
Recap Summary of Chapter 6 Interpolation Linear Interpolation.
MA/CS 3751 Fall 2002 Lecture 24. MA/CS 3752 ginput ginput is a Matlab function which takes one argument input: number of points to select in the image.
Two-Point Perspective
Spatial Statistics in Ecology: Continuous Data Lecture Three.
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room A, Chris Hill, Room ,
Advanced Computer Graphics Advanced Shaders CO2409 Computer Graphics Week 16.
Outline Announcements –HW II due Friday –HW III option Interpolation Colormaps.
Introduction to MATLAB Session 5 Simopekka Vänskä, THL 2010.
1 Artificial Intelligence: Vision Stages of analysis Low level vision Surfaces and distance Object Matching.
Parametric Surfaces Define points on the surface in terms of two parameters Simplest case: bilinear interpolation s t s x(s,t)x(s,t) P 0,0 P 1,0 P 1,1.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
2D Routines in 3D. Outline Announcements –HW II--due Friday. 5PM HW1 & Cookie Grids & Meshes Representing f(x,y) Lines & Surfaces in 3D Survey.
CS 325 Introduction to Computer Graphics 03 / 29 / 2010 Instructor: Michael Eckmann.
Numerical Analysis 3D Plots. A numerical method is a technique for computing a numerical approximation of the solution to a mathematical problem.
Recap Plots with More than one Line Plots of Complex Arrays Line, Color and Mark Style Axis Scaling and Annotating Plots Subplots Polar Plots Logarithmic.
Volumetric Visualization. Outline Announcements –PS III due today –contest entries by tomorrow –PS IV online today--GUI vs. VV –Demos on Friday What is.
Recap Cubic Spline Interpolation Multidimensional Interpolation Curve Fitting Linear Regression Polynomial Regression The Polyval Function The Interactive.
June 14, ‘99 COLORS IN MATLAB.
In the name of God Computer Graphics Bastanfard. Curve Function(2) Other method is approximate it using a poly-line. Just locate a set of points along.
Interactive Graphics Lecture 10: Slide 1 Interactive Computer Graphics Lecture 10 Introduction to Surface Construction.
CS COMPUTER GRAPHICS LABORATORY. LIST OF EXPERIMENTS 1.Implementation of Bresenhams Algorithm – Line, Circle, Ellipse. 2.Implementation of Line,
11/5/2002 (c) University of Wisconsin, CS 559 Last Time Local Shading –Diffuse term –Specular term –All together –OpenGL brief overview.
Introduction to Engineering Calculations Chapter 2.
Data Visualization Fall The Data as a Quantity Quantities can be classified in two categories: Intrinsically continuous (scientific visualization,
Introduction to Meshes Lecture 22 Mon, Oct 20, 2003.
David Luebke3/16/2016 CS 551 / 645: Introductory Computer Graphics David Luebke
EEE 242 Computer Tools for Electrical Engineering
1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Marching Squares Ed Angel Professor Emeritus of Computer Science University.
3D Ojbects: Transformations and Modeling. Matrix Operations Matrices have dimensions: Vectors can be thought of as matrices: v=[2,3,4,1] is a 1x4 matrix.
Advanced Plotting Techniques Chapter 11 Above: Principal contraction rates calculated from GPS velocities. Visualized using MATLAB.
2D Routines in 3D.
3D Graphics Rendering PPT By Ricardo Veguilla.
Grids Geometry Computational Geometry
Craig Schroeder October 26, 2004
Grids Geometry Computational Geometry
Three –Dimensional Figures
Spatial interpolation
Coordinate Transformation in 3D Final Project Presentation
Computer Graphics Material Colours and Lighting
Physical Problem of Simultaneous Linear Equations in Image Processing
Presentation transcript:

interpolation, color, & light

Outline Announcements –HW II--due today, 5PM –HW III on the web later today HW I: Issues Structured vs. Unstructured Meshes Working with unstructured meshes Interpolation colormaps lights

HW I No issues on the programs--most did well –sample solutions are on the web No problems figuring out colors or finding handles –if you don’t understand a question, come find me! Only one person got 1 correct –This was a bit of a trick question, but … –since you have to go to the computer to do the programming, you might as well try the problems

Interpolation & grids To plot with surfaces, you need some kind of mesh or grid: –a mesh is a collection of non-overlapping polygons that fills a region of space –meshes can be structured (all polygons the same size and shape) or unstructured

Regular Grids Meshes made from quadrilaterals are known as grids –A regular grid has only 90° angles (rectangles) and can be defined by vectors x and y –if x(j+1)-x(j) and y(j+1)-y(j) are constant, then the grid is uniform x(1) x(2) x(3) x(4) x(5) y(6) y(5) y(4) y(3) y(2) y(1)

Unstructured Grids If the cells are not rectangular, then the grid is irregular or unstructured X and Y are now matrices:

Visualizing Grids Matlab’s core 2D functions want grids: –pcolor –contour –surf –mesh

The World is not Square Meshes of triangles are common, especially in finite element modlling Triangular meshes can also be structured or unstructured –unstructured are more common

Matrices are rectangular, so it is hard to “fit” a triangular mesh into a matrix Typically, triangular meshes require 3 arrays: –vectors x and y contain the location of the vertices (in no particular order) –array tri defines how the vertices are connected Each row contains indexes the three vertices forming a triangle Triangular Meshes tri=[1 4 2; 2 4 3]; (x(3),y(3))

Matlab’s trimesh is designed to plot z=t f(x,y) on a triangular mesh –trimesh(tri, x,y,z, {c}); We can do the same thing with patch (or surface) –we may not be interested (or have) z and c –this is mainly to illustrate the form of x, y, z, and c data fields Plotting Triangular Meshes

h=patch(X,Y,C) creates polygons for each column of X,Y, and C –if our mesh has t triangles, X, Y, and C will be 3-by-t –X=[x(tri(:,1)), x(tri(:,2)), x(tri(:,3))]’; The mesh will be plotted in 2D view with flat color: triangle colors will be set by the first vertex (first row of C); Patching Triangular Meshes

Suppose we want to make it 3D with elevation set by C –patch(X,Y,C,C) will work (C used for both elevation and color) or, if we’ve already plotted, with h=patch(X,Y,C): –set(h,’zdata’,C);view(3) Patching Triangular Meshes

If we want to plot with surfaces (or patches), we need some kind of mesh But, we are rarely able to sample on a grid –observations are often made at irregular intervals of time and space due to sampling constraints or equipment error (missing data) It is possible to calculate what the observations should’ve been at locations where we didn’t sample –This is known as interpolation Interpolation

It is possible to calculate what the observations should’ve been at locations where we didn’t sample –This implies that we know something about the system we’re observing –But, if we know so darn much, why bother observing? –The bottom line is that we are creating data and we have no way of knowing whether or not we’ve done this correctly All interpolations should be treated with suspicion

Formal Statement of Problem Inputs: –Xobs= locations where we observed data (time, space, etc., can also have Yobs, Zobs) –Vobs= observed values: Vobs=f(Xobs) Remember, we don’t know the exact form of f, but we may know something about its structure –X=locations where we would like to know the values Then, –V=INTERPMETHOD(Xobs, Vobs, X) –Ideally, we have enough observations and know enough about f so that INTERPMETHOD ≈ f

Linear Interpolation Linear interpolation is the simplest form of interpolation (other than picking a constant) –If we have two observations, we can fit a line between them and use the equation of the line to determine v –linear interpolation is used implicitly when plotting with lines or using interpolated shading x Xobs(1) Xobs(2) Vobs(2) Vobs(1) V

Linear Interpolation in Matlab Matlab’s interpolation routines use linear interpolation by default –V=interp1(Xobs, Vobs, X) –V=interp2(Xobs, Yobs, Vobs, X, Y) Xobs, and Yobs must define a grid (i.e. same form as inputs for pcolor or surface) interp3, interpN work for higher-dimensional data –V=griddata(Xobs, Yobs, Vobs, X, Y) observations need not be gridded uses Delaunay triangulation

Higher-order Interpolation Matlab can also interpolate using cubic functions or splines –v=interp1(xobs, vobs, x, ‘spline’); –the results are smoother, but potentially very wrong

Objective Analysis and Kriging Matlab’s default interpolation schemes are simple, but stupid Kriging (a.k.a objective analysis) is a statistical interpolation technique –requires you to know (or guess) the structure of your data’s spatial variance distance variance (dissimilarity)

In kriging, Error=f(distance) –Assumes your knowledge about v declines as you move away from your observations –Can often determine error function from your observations v(j)=w1*vobs(1)+w2*vobs(2)+…+wn*vobs(n) –The v’s are weighted means of the observations, the weights are determined by the distance from v(j) according to the error function –In addition to v, we can also get an estimate of the interpolation error Kriging

Kriging in Matlab Kriging is computationally simple, but there are some statistical condiderations – Matlab does not have a built-in kriging function (that I know of) – y_krig/easy_krig.html –other software exists

Colormaps Matlab colormaps are m-by-3 matrices, where each row is an RGB vector When a color property (face or edge) is set to flat or interp, Matlab will determine the color using Cdata, Clim, and the colormap cdata Clim(1) Clim(2)

Colormaps Built in colormaps (help graph3d) –map=copper(N);--gets copper colormap with N rows –map=colormap--gets current colormap (default is jet) –colormap(map);--sets colormap to map map could be a built-in colormap (copper) Colormap is a property of the figure, not the axes –This means that we can have only one colormap per figure

Creating New Colormaps Matlab colormaps are usually adequate, but will need to create your own if: –You need more than one map/figure –You don’t like Matlab’s

Creating New Colormaps Simplest approach is modify Matlab’s –map=colormap(gray);map=flipud(map); map will go from black to white rather than white to black –brighten lets you “brighten” or “darken” current colormap Create your own with interp1 –v=[1 3 4]’; col=[ ; ; 1 1 0]; –map=interp1(v,col,linspace(1,4,64)’, ‘cubic’);

Multiple Colormaps Working with multiple colormaps gets very complicated –requires lots of handle graphics work Tips & Things to remember –Single Clim-space, so pick something simple [0 1],[-2 1] –Transform actual clims to this space Data 1 Data 2

Example: Gulf of Maine Bathymetry Today, I’ll start leading you through the process of creating my Gulf of Maine visualizations We’ll start with the bathymetry and add the temp (blue stuff) next week This figure has two surfaces and uses 3 colormaps and two light sources

Lighting With the colors used, it is impossible to see features in the Gulf of Maine Matlab allows you to add light sources –Reflections can enhance 3D perspective

Lighting Lighting is tough & involves a lot of trial and error –1. Make sure your surface can be lit: Lighting phong (or gourard or flat) sets the ‘facelighting’ property of your surface It will now reflect light in a “natural” way Setting backfacelighting to lit is also good –2. Add a light L=light(light options) creates a light object –Control its position, color, and distance (infinite vs. local) camlight(az,el) creates a light source relative to you (the camera)

Lighting Lighting is not for the faint of heart, but here are some tips: –set(gcf,’renderer’,’opengl’) gives better output and performance –Keep track of handles to lights Turn them on or off (change visibility) Move them around