INTRODUCTION TO MATLAB PART4 Further GRAPHICS - PowerPoint PPT Presentation

1 / 21
About This Presentation
Title:

INTRODUCTION TO MATLAB PART4 Further GRAPHICS

Description:

All Matlab graphics output is created in units of graphics objects with ... image pixel data will be accurately representable by 8bits a Matlab data type ... – PowerPoint PPT presentation

Number of Views:30
Avg rating:3.0/5.0
Slides: 22
Provided by: Grif157
Category:

less

Transcript and Presenter's Notes

Title: INTRODUCTION TO MATLAB PART4 Further GRAPHICS


1
INTRODUCTION TO MATLAB PART4- Further GRAPHICS
  • UNIVERSITY OF SHEFFIELD
  • CiCS DEPARTMENT
  • Deniz Savas Mike Griffiths
  • JANUARY.2007

2
PART 4TOPICS
  • Handle Graphics
  • Basic 3D Graphics
  • Animation and Movies
  • Displaying Bit-Mapped Images
  • Visualisation aids with camera lighting and
    transparency

3
Anatomy of Matlab Graphics
  • Handle Graphics
  • Animations

4
Handle Graphics
  • All Matlab graphics output is created in units of
    graphics objects with associated properties and a
    tree structured hierarchical dependency. User can
    manipulate these objects by changing their
    properties. The following diagram shows all the
    possible Matlab Graphics Objects and their
    hierarchy.

5
Graphics Objects
6
Graphics Objects
  • The Root Contains everything
  • Figure Individual Graphics Window
  • Uicontrols User interface icons usually created
    by GUIDE utility.
  • Axes defines mapping from real coordinates to
    screen coordinates
  • Image A Matlab image consists of a data-matrix
    and possibly a colormap vector.
  • Light Defines the position and color of light
    sources. These effect patch and surface objects
  • Line, patch, rectangle self explanatory
  • Surface A surface object is the 3D
    representation of matrix data where the element
    values are assumed to contain the z-coordinates.
  • Text Character strings drawn on the figure. (
    labels etc. )

7
Querying and Setting Object Properties
  • Value get( object_handle, Property Name )
  • set(object_handle,Property Name ,newvalue)
  • Special symbol gca refers to the current axes
    object. get(gca) returns all its properties.
    Having found out what the property names are a
    subsequent set(gca , Property Name, newval )
    can be used to change a given property.
  • Best way of familiarising is by using the
    property editor after a graph is drawn.
  • Similarly gcf for Current Figure Object can be
    used
  • Most other objects handles have to be obtained
    during the creation by using the function in the
    form handle function( )
  • For example h plot( X, Y )

8
Viewpoint
  • Matlab allows us to re-define the viewing
    direction of the eye for 3D plots.
  • This direction is defined by two terms namely
  • Azimuth the angle with the y axis
  • and
  • Elevation angle with the x/y plane.

9
view position and camera
  • az elview ---gt return the current eye
    location in two scalars az and el.
  • view( az , el ) ---gt set eye location.
  • view(3) ---gt set to default 3D view
  • el90 directly above -90 directly below.
  • Camera Toolbar
  • In the Figure Window, select the View-gtCamera
    Toolbar option. This will display a set of icons
    which gives full control to the camera position
    that controls the view.

10
Animations with Matlab
  • There are two distinct methods for creating
    animations
  • By means of movies ( useful for complex
    pictures)
  • By using the erase or xor mode of graphics and
    drawing and redrawing on the same graph.

11
Matlab Movies
  • Create the movie as a set of captured frames that
    can be displayed one after the other thus
    creating the effect of a movie.
  • Commands are getframe and movie
  • Example
  • The following code captures the fast forrier
    transforsm of a series of step functions plots
    them and stores the plotted output in a structure
    named M which contains the bit-map data ( as type
    uint8 matrix and the colour-map
  • for k 116
  • plot( fft(eye(k16) ) )
  • axis equal
  • M(k) getframe
  • end
  • and the captured frames can be played back by
    typing movie(M)

12
Animation by using the erase modes
  • Techniques used by Matlab for drawing or
    redrawing a graphics object is determined by that
    objects EraseMode property. By default all
    objects EraseMode properties are Normal. This
    means that when any one of a Matlab Graphics
    Objects property that effects its visibility
    changes, Matlab erases that object and redraws it
    while taking care of all the 3D hidden
    surface/line aspects.
  • This is why when you use the property editor
    to edit a Matlab Graph it gets redrawn
    automatically.
  • However this behaviour can be altered by
    setting the EraseMode property of an object to
    one of
  • None Do not erase the object when it moves or
    alters.
  • Background Erase the object by redrawing it in
    the background colour
  • Xor Erase only the object by Exclusive OR ing
    the graphics area with the objects pixels.

13
Practice Session 13 Animation
  • In the examples/animation directory, there is a
    script called makemov.m
  • View this script and run it to save a movie
    matrix and replay the saved movie by using the
    movie command.
  • In the same directory study and run the script
    named animateroot
  • Study the scripts animpeaks1 and animpeaks2
    noting the use of the set function to update the
    graphics. Use the profiler to compare the two
    scripts

14
Matlab Images
  • Graphics features of Matlab we have seen so far
    were related to creating of images by mostly
    vector graphics techniques. We are now going to
    study the manipulating and displaying of
    previously captured images.
  • Whatever the format, fundamentally images are
    represented as two or three dimensional arrays
    with each element representing the colour or
    intensity of a particular pixel of the picture.
  • It would be perfectly valid to represent such
    image data as ordinary ( double precision) Matlab
    Matrices but the memory required to store a say
    1000 by 1000 image will 8 Mbytes which is too
    extravagant.
  • As most image pixel data will be accurately
    representable by 8bits a Matlab data type named
    uint8 ( unsigned integer) is normally used for
    image data handling. This reduces the memory
    requirement to 1/8th !

15
Matlab image Types
  • A Matlab image consists of a data-matrix and
    possibly a colourmap matrix. The following three
    different image types are used
  • Indexed Images
  • Intensity Images
  • RGB (TrueColour) Images

16
Indexed Images
  • These are stored as a two dimensional array of
    image data a colourmap matrix.
  • The colour-map matrix is a m-rows by 3 columns
    matrix with each of the rows representing a
    colour defined by the three R,G,B components
    (ranging 0.0 to 1.0) of that colour. The image
    data contains indexes to this colour map matrix.
  • The colormap is usually stored with the image and
    saved/loaded by the imwrite/imread functions.

17
Intensity Images
  • Image is a 2 dimensional Matrix whose each
    element is scaled by Matlab to produce a colormap
    index. The colormap index is an m by 3 array as
    in the indexed images, although this colourmap
    index is used during display it is not stored as
    part of the image as it can always be deduced
    from the data. These image forms are normally
    used for gray-scale type images where only the
    intensity is important.

18
RGB Images
  • Sometimes known as Truecolor images the data is
    stored as an n-m-3 image. I.e. m by n with 3
    planes. These 3 planes represent the R,G and B
    components of the pixel respectively. There are
    normally 8 bits allocated to the representation
    of each colour making it 2(38)
    22416Million possible colours.
  • There is no colormap array for RGB images as all
    the colour information is contained in the data
    matrix.

19
Handling Graphics Images
  • Reading/Writing Graphics Images
  • imread , imwrite
  • load , save ( if only the image was saved as a
    MAT file)
  • Displaying Graphics Images
  • image
  • imagesc
  • Utilities
  • imfinfo
  • ind2rgb

20
Practice session-14
  • Find out information about the image file named
    sunset.jpg in the top level of the exercise
    directory by using the imfinfo function.
  • Read this image into Matlab
  • Display this image on the screen
  • Edit the image figure and investigate its
    properties.

21
THE END
Write a Comment
User Comments (0)
About PowerShow.com