Matlab for Visualization Ray Gasser IS&T Scientific Visualization Tutorial – Spring 2010.

Slides:



Advertisements
Similar presentations
MATLAB – A Computational Methods By Rohit Khokher Department of Computer Science, Sharda University, Greater Noida, India MATLAB – A Computational Methods.
Advertisements

Introduction to MATLAB The language of Technical Computing.
Graphics Pipeline.
Visualization Data Representation Ray Gasser SCV Visualization Workshop – Fall 2008.
Chapter 11 Above: Principal contraction rates calculated from GPS velocities. Visualized using MATLAB.
3D Graphics Rendering and Terrain Modeling
ES 314 Lecture 2 Sep 1 Summary of lecture 1: course overview intro to matlab sections of Chapters 2 and 3.
ParaView Tutorial Greg Johnson, Karla Vega. Before we begin… Make sure you have ParaView installed so you can follow along in the lab section –
Shared Graphics Skills Cameras and Clipping Planes
HCI 530 : Seminar (HCI) Damian Schofield. HCI 530: Seminar (HCI) Transforms –Two Dimensional –Three Dimensional The Graphics Pipeline.
HCI 530 : Seminar (HCI) Damian Schofield.
Scientific Visualization with ParaView Ray Gasser IS&T Scientific Visualization Tutorial – Spring 2010.
17 VECTOR CALCULUS.
Introduction to Volume Visualization Mengxia Zhu Fall 2007.
2.1 si SI31 Advanced Computer Graphics AGR Lecture 2 Basic Modelling.
MATLAB Week 3 17 November Outline Graphics – Basic plotting – Editing plots from GUI – Editing plots from m-file – Advanced plotting commands.
Scientific Visualization Using MATLAB Robert Putnam Scientific Visualization Using MATLAB - Spring 2015.
IS&T Scientific Visualization Tutorial - Summer 2010 Scientific Visualization Tutorial.
Scenes, Cameras & Lighting. Outline  Constructing a scene  Using hierarchy  Camera models  Light models.
Scalar and Vector Fields
Introduction to 3D Graphics John E. Laird. Basic Issues u Given a internal model of a 3D world, with textures and light sources how do you project it.
 1999 BG Mobasseri1 8/29/2015 MATLAB GRAPHICS - PART II ADVANCED PLOTTING June 4, ‘99.
Introduction to 3D Computer Graphics and Virtual Reality McConnell text.
Copyright - Planchard 2012 History of Engineering Graphics Stephen H. Simmons TDR 200.
Technology and Historical Overview. Introduction to 3d Computer Graphics  3D computer graphics is the science, study, and method of projecting a mathematical.
Geometric Transformation. So far…. We have been discussing the basic elements of geometric programming. We have discussed points, vectors and their operations.
CMPS 1371 Introduction to Computing for Engineers PLOTTING.
Plotting – 3-Dimensional. 3D Plots versus 2D Plots 3-dimensional plots, in contrast to 2-dimensional ones, has a third axis (often called the z-axis).
ELG 3120 Signal and System Analysis 1 Introduction to MATLAB TAs Wei Zhang Ozgur Ekici (Section A)(Section B) ELG 3120 Lab Tutorial 1.
CDS 301 Fall, 2009 Vector Visualization Chap. 6 October 7, 2009 Jie Zhang Copyright ©
MATLAB Week 4 01 December Outline More plotting – A few other 3-D plotting functions – Basic volume visualization Creating functions Vectorized.
Khoros Yongqun He Dept. of Computer Science, Virginia Tech.
1 Computer Programming (ECGD2102 ) Using MATLAB Instructor: Eng. Eman Al.Swaity Lecture (1): Introduction.
Advanced GIS Using ESRI ArcGIS 9.3 3D Analyst part 2.
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room A, Chris Hill, Room ,
CDS 301 Spring, 2013 CH3: MATLAB 3-D Visualization February 07, TBD Jie Zhang Copyright ©
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is protected by Copyright.
Introduction to MATLAB Session 5 Simopekka Vänskä, THL 2010.
Scientific Visualization Using MATLAB Robert Putnam Scientific Visualization Using MATLAB - Spring 2011.
Volume Visualization Presented by Zhao, hai. What’ volume visualization Volume visualization is the creation of graphical representations of data sets.
OpenGL The Viewing Pipeline: Definition: a series of operations that are applied to the OpenGL matrices, in order to create a 2D representation from 3D.
2D Routines in 3D. Outline Announcements –HW II--due Friday. 5PM HW1 & Cookie Grids & Meshes Representing f(x,y) Lines & Surfaces in 3D Survey.
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.
EGR 106 Lecture 6 2-D Plotting Graphical presentation has become the standard method to show technical information. Engineers use plots to analyze, visualize,
Scientific Visualization Using MATLAB - Fall 2012
Data Visualization Fall 2015.
© Tan,Steinbach, Kumar Introduction to Data Mining 8/05/ Data Mining: Exploring Data Lecture Notes for Chapter 3 Introduction to Data Mining by Tan,
Visualization with ParaView. Before we begin… Make sure you have ParaView 3.14 installed so you can follow along in the lab section –
12/24/2015 A.Aruna/Assistant professor/IT/SNSCE 1.
ELG 3120 Lab 2 TAs Wei Zhang Ozgur Ekici (Section A) (Section B)
June 14, ‘99 COLORS IN MATLAB.
CS COMPUTER GRAPHICS LABORATORY. LIST OF EXPERIMENTS 1.Implementation of Bresenhams Algorithm – Line, Circle, Ellipse. 2.Implementation of Line,
CHAPTER 5 CONTOURING. 5.3 CONTOURING Fig 5.7. Relationship between color banding and contouring Contour line (isoline): the same scalar value, or isovalue.
Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Lab 10: 3D & Projections Advanced.
2/24/2016 A.Aruna/Assistant professor/IT/SNSCE 1.
MATLAB ® for Engineers, Holly Moore Fourth Edition, Global Edition © Pearson Education Limited 2015 All rights reserved. Figure 5.1 Simple Plot of Time.
More Matlab Graphics and GUI Graphics subplots some useful commands 3D graphics GUI GUI controls The callback property Other essential properties.
Geometric Transformations Ceng 477 Introduction to Computer Graphics Computer Engineering METU.
An Introduction to Programming in Matlab Emily Blumenthal
EEE 242 Computer Tools for Electrical Engineering
Chapter 1 Computing Tools Variables, Scalars, and Arrays Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
1 CW11 Visualizing ACE3P Results in ParaView Greg Schussman Menlo Park, CA October 10, 2011.
Reading and Writing Image Files
© University of Wisconsin, CS559 Spring 2004
3D-Graphs A 3D surface is defined as: z = f(x, y)
Lecture 25.
Ch3 Graphics Overview of Plotting Editing Plots
3D Graphics Rendering PPT By Ricardo Veguilla.
CSCI N317 Computation for Scientific Applications Unit 1 – 5 MATLAB
Presentation transcript:

Matlab for Visualization Ray Gasser IS&T Scientific Visualization Tutorial – Spring 2010

MATLAB MATrix LABoratory –high performance language for technical computing –interpreted language (compiler available) –interactive GUI –command line interface (Command Window) –application specific toolboxes available (Parallel Computing, Statistics, etc.) –coupled with Maple for Symbolic computation –good documentation available (user guides, demos, videos, etc.) –professional support services available from MathWorks IS&T Scientific Visualization Tutorial – Spring 2010

MATLAB – Data Types Matrix –the basic data type is the matrix/array –a vector is just a 1D array –2 facilities available for displaying vectors and matrices as graphs MATLAB interactive GUI plotting tool MATLAB graphics commands from the Command Window IS&T Scientific Visualization Tutorial – Spring 2010

MATLAB – Data Types IS&T Scientific Visualization Tutorial – Spring 2010 Volume Data –data defined on three-dimensional grids –multidimensional arrays of scalar or vector data –defined on lattice structures representing values sampled in 3-D space –2 basic types Scalar volume data single data values for each point examples: temperature, pressure, density, elevation Vector volume data two or three values for each point (components of a vector) magnitude and direction examples: velocity, momentum

MATLAB - Graphics Model Graphics Model –used to create visual representations of data –two basic types of graphics objects: Core graphics objects lines text rectangles patches (filled polygons) surfaces (3D grid of vertices) images (2D matrix representation of image) light sources axes (define coordinate system) Composite graphics objects core graphics objects grouped together IS&T Scientific Visualization Tutorial – Spring 2010

MATLAB – figure function Figure –all graphical output directed to a graphics window called a figure –separate from the Command Window –can contain menus, toolbars, user-interface objects, context menus, axes, or any other type of graphics object. – to create a new figure, use the figure function (type figure in a Command Window) IS&T Scientific Visualization Tutorial – Spring 2010

Code – figure function Command Window figure IS&T Scientific Visualization Tutorial – Spring 2010

MATLAB - Properties Properties –every graphics object has a set of properties associated with it –defines different attributes of an object, such as its color, size, position, etc. –usually specified by name/property pairs –figure( 'PropertyName', propertyvalue,...) –can be set at creation time or later by using the set function Command Window f = figure set (f, 'Name','Test Window') IS&T Scientific Visualization Tutorial – Spring 2010

Code – property list Command Window figure('Name','Test Window','Position',[ ],'MenuBar','none') IS&T Scientific Visualization Tutorial – Spring 2010

MATLAB - Viewing Viewing –the process of displaying a graphical scene from various directions by adjusting the camera position, changing the perspective, changing the aspect ratio, etc. –the particular orientation you set to display the visualization –composed from two basic functions: positioning the viewpoint to orient the scene – view function setting the aspect ratio and relative axis scaling – axis function IS&T Scientific Visualization Tutorial – Spring 2010

MATLAB – view function view –the viewpoint is specified by defining azimuth and elevation with respect to the axis origin –azimuth is a polar angle in the x-y plane, with positive angles indicating counterclockwise rotation of the viewpoint. Elevation is the angle above (positive angle) or below (negative angle) the x-y plane. IS&T Scientific Visualization Tutorial – Spring 2010

MATLAB – view function (cont) view –MATLAB automatically selects a viewpoint that is determined by whether the plot is 2-D or 3-D For 2-D plots, the default is azimuth = 0° and elevation = 90° For 3-D plots, the default is azimuth = -37.5° and elevation = 30° –view(2) sets the default 2D view, with az = 0, el = 90. –view(3) sets the default 3D view, with az = –37.5, el = 30. –view(az,el) or view([az,el]) set the viewing angle for a 3D view. IS&T Scientific Visualization Tutorial – Spring 2010

Code – view function Command Window Z = peaks(20); figure; h = surf(Z); view([-20,25]); IS&T Scientific Visualization Tutorial – Spring 2010 The peaks function is an example function of two variables, obtained by translating and scaling Gaussian distributions. peaks(n) returns an n-by-n matrix The surf function create 3-D surface plots of matrix data.

MATLAB – axis function axis –enables you to adjust the aspect ratio of graphs. –enables you to adjust the scaling of graphs. –axis([xmin xmax ymin ymax zmin zmax]) sets the limits for the x-axis, y-axis and z-axis of the current axes. –axis vis3d freezes aspect ratio properties to enable rotation of 3-D objects (If you will be interactively rotating the visualization in the figure window you should use the vis3d option.) IS&T Scientific Visualization Tutorial – Spring 2010

Code – axis function Command Window Z = peaks(20); figure; h = surf(Z); view([-20,25]); axis([ ]); IS&T Scientific Visualization Tutorial – Spring 2010

MATLAB - Lighting Lighting –enhances the visibility of surface shape and provides a 3D perspective to your visualization. –several commands enable you to position light sources and adjust the characteristics of lit objects: light - creates a light object lighting - selects a lighting method material - sets the reflectance properties of lit objects camlight - creates or moves a light with respect to the camera position shading - controls the color shading of surface and patch graphic objects IS&T Scientific Visualization Tutorial – Spring 2010

Code - lighting Command Window Z = peaks(20); figure; h = surf(Z); view(3); axis on; light; lighting phong; camlight('left'); shading interp; IS&T Scientific Visualization Tutorial – Spring 2010

MATLAB – Vis Algorithms Modeling –Matrix to Surface –Slicing Scalar –Color Mapping –Contours / Isosurfaces Vector –Oriented Glyphs –Streamlines IS&T Scientific Visualization Tutorial – Spring 2010

MATLAB – modeling algorithms Matrix to Surface –a surface is defined by the z-coordinates of points above a rectangular grid in the x-y plane. –formed by joining adjacent points with straight lines. –useful for visualizing large matrices. –surf(X,Y,Z) creates a shaded surface using Z for the color data as well as surface height. X and Y are vectors or matrices defining the x and y components of a surface. IS&T Scientific Visualization Tutorial – Spring 2010

Code – surf function Command Window [X,Y] = meshgrid(-3:0.25:3); Z = peaks(X,Y); figure; surf(X,Y,Z); view(3); axis([ ]); grid on; light; lighting phong; camlight('left'); IS&T Scientific Visualization Tutorial – Spring 2010 meshgrid(x,y) transforms the domain specified by vectors x and y into arrays X and Y, which can be used to evaluate functions of two variables and three-dimensional mesh/surface plots. meshgrid(x) is the same as [X,Y] = meshgrid(x,x).

MATLAB – modeling algorithms Slicing –a slice is a "cross-section" of the dataset. –any kind of surface can be used to slice the volume. –the simplest technique is to use a plane to define the cutting surface. –slice (X,Y,Z,V,sx,sy,sz) draws slices of the volume V along the x, y, z directions in the volume V at the points in the vectors sx, sy, and sz. X, Y, and Z are 3D arrays specifying the coordinates for V. –the color at each point is determined by 3-D interpolation into the volume V. IS&T Scientific Visualization Tutorial – Spring 2010

Code – slice function Command Window [x,y,z,v] = flow; figure; xslice = 5; yslice = 0; zslice = 0; slice(x,y,z,v,xslice,yslice,zslice); view(3); axis on; grid on; light; lighting phong; camlight('left'); shading interp; IS&T Scientific Visualization Tutorial – Spring 2010 The flow dataset represents the speed profile of a submerged jet within an infinite tank (an example of scalar volume data).

MATLAB – scalar algorithms Color Mapping –each scalar value in data set is mapped through a lookup table to a specific color. –the color lookup table is called the colormap a three-column 2-D matrix each row of the matrix defines a single color by specifying three values in the range of zero to one (RGB components). created with either array operations or with one of the several color table generating functions (jet, hsv, hot, cool, summer, and gray). colormap(map) sets the colormap to the matrix map. IS&T Scientific Visualization Tutorial – Spring 2010

Code – colormap function Command Window [x,y,z,v] = flow; figure; xslice = 5; yslice = 0; zslice = 0; slice(x,y,z,v,xslice,yslice,zslice); view(3); axis([ ]); grid on; colormap (flipud(jet(64))); colorbar('vertical'); shading interp; IS&T Scientific Visualization Tutorial – Spring 2010

MATLAB – colormap editor If you want even more control over the color mapping, you can use the colormap editor. You open the colormap editor by selecting Colormap from the Edit menu of the figure. IS&T Scientific Visualization Tutorial – Spring 2010

MATLAB – scalar algorithms Contours / Isosurfaces –constructs a boundary between distinct regions in the data. –contours are lines or surfaces of constant scalar value. –isolines for two-dimensional data and isosurfaces for three-dimensional data. –contour(X,Y,Z,v) draws a contour plot of matrix Z with isolines at the data values specified in the vector v. –isosurface(X,Y,Z,V,isovalue) computes isosurface data from the volume data V at the isosurface value specified in isovalue. The isosurface function connects points that have the specified value the same way isolines connect points of equal elevation. IS&T Scientific Visualization Tutorial – Spring 2010

Code – contour function Command Window [X,Y] = meshgrid(-3:0.25:3); Z = peaks(X,Y); figure; isovalues = (-3.0:0.5:3.0); contour(X,Y,Z,isovalues); view(2); axis on; grid on; IS&T Scientific Visualization Tutorial – Spring 2010

Code – isosurface function Command Window [x,y,z,v] = flow; isovalue = -1; purple = [ ]; figure; p = patch(isosurface(x,y,z,v,isovalue)); isonormals(x,y,z,v,p); set(p,'FaceColor',purple,'EdgeColor','none'); view([-10 40]); axis on; grid on; light; lighting phong; camlight('left'); IS&T Scientific Visualization Tutorial – Spring 2010 patch is the low-level graphics function that creates patch graphics objects. A patch object is one or more polygons defined by the coordinates of its vertices.

MATLAB – vector algorithms Oriented Glyphs –draw an oriented, scaled glyph for each vector. –glyphs are polygonal objects such as a cone or an arrow. –orientation and scale of glyph indicate the direction and magnitude of the vector. –glyph may be colored according to vector magnitude or some other scalar value. –coneplot(X,Y,Z,U,V,W,Cx,Cy,Cz) plots vectors as cones or arrows. X, Y, Z define the coordinates for the vector field U, V, W define the vector field Cx, Cy, Cz define the location of the cones in the vector field coneplot(...,'quiver') draws arrows instead of cones. IS&T Scientific Visualization Tutorial – Spring 2010

Code – coneplot function Command Window load wind; xmin = min(x(:)); xmax = max(x(:)); ymin = min(y(:)); ymax = max(y(:)); zmin = min(z(:)); zmax = max(z(:)); scale = 4; figure; [cx cy cz] = meshgrid(xmin:5:xmax,ymin:5:ymax,zmin:2:zmax); coneplot(x,y,z,u,v,w,cx,cy,cz,scale,'quiver'); view([-35 60]); axis on; grid off; IS&T Scientific Visualization Tutorial – Spring 2010 The wind dataset represents air currents over North America. The dataset contains six 3-D arrays: x, y, and z are coordinate arrays which specify the coordinates of each point in the volume and u, v, and w are the vector components for each point in the volume.

MATLAB – vector algorithms Streamlines –the path a massless particle takes flowing through a velocity field (i.e. vector field) –can be used to convey the structure of a vector field by providing a snapshot of the flow at a given instant in time. –multiple streamlines can be created to explore interesting features in the field. –computed via numerical integration (integrating product of velocity times delta T). –streamline(X,Y,Z,U,V,W,startx,starty,startz) draws stream lines from the vector volume data. X, Y, Z define the coordinates for the vector field U, V, W define the vector field startx, starty, startz define the starting positions of the streams IS&T Scientific Visualization Tutorial – Spring 2010

Code – streamline function Command Window load wind; xmin = min(x(:)); xmax = max(x(:)); ymin = min(y(:)); ymax = max(y(:)); zmin = min(z(:)); zmax = max(z(:)); purple = [ ]; figure; [sx sy sz] = meshgrid(xmin,ymin:10:ymax,zmin:2:zmax); h = streamline(x,y,z,u,v,w,sx,sy,sz); set(h,'LineWidth',1,'Color',purple); view([-40 50]); axis on; grid off; IS&T Scientific Visualization Tutorial – Spring 2010

MATLAB - Resources IS&T tutorials –Introduction to MATLAB –Using MATLAB to Visualize Scientific Data Websites – – – Wiki – MATLAB Workshop end March beginning April 2010 IS&T Scientific Visualization Tutorial – Spring 2010

Sources Getting Started with MATLAB, version 7, The MathWorks, Inc. Using MATLAB, version 7, The MathWorks, Inc. Using MATLAB Graphics, version 7, The MathWorks, Inc. IS&T Scientific Visualization Tutorial – Spring 2010