Download presentation
Presentation is loading. Please wait.
Published byShon Phillips Modified over 9 years ago
1
Spring 2007 1R. Smith - University of St Thomas - Minnesota QMCS 130: Today’s Class Final Exam – rest of class scheduleFinal Exam – rest of class schedule Where we areWhere we are 2D Graphics2D Graphics Graphics in MatlabGraphics in Matlab Game of LifeGame of Life
2
Spring 2007 2R. Smith - University of St Thomas - Minnesota Where we Are Using Matlab to do arithmeticUsing Matlab to do arithmetic Math on Scalars and vectorsMath on Scalars and vectors Writing scripts and functionsWriting scripts and functions Control Structures: if, while, forControl Structures: if, while, for Strings and TextStrings and Text Lab 5Lab 5
3
Spring 2007 3R. Smith - University of St Thomas - Minnesota 2D Graphics – Black & White How do we represent a picture with numbers?How do we represent a picture with numbers? Basic version: bitmapped graphicBasic version: bitmapped graphic –2D matrix, each element is binary: 0=white, 1=black Grayscale graphicsGrayscale graphics –2D matrix, each element gives the intensity of the image –Direction varies with implementation Is white > black, or black > white?Is white > black, or black > white? –Representation varies Integer range from 0-255, 32767, etc.Integer range from 0-255, 32767, etc. Rational range: 0.0 -> 1.0 or alternativesRational range: 0.0 -> 1.0 or alternatives Matlab likes the rational rangeMatlab likes the rational range –Also handles grayscale
4
Spring 2007 4R. Smith - University of St Thomas - Minnesota 2D Graphics - Color Questions:Questions: Which ‘primary’ colors do the numbers represent?Which ‘primary’ colors do the numbers represent? –Additive vs Subtractive Colors What numbers do we provide?What numbers do we provide? Do we use shortcuts to reduce the image size?Do we use shortcuts to reduce the image size?
5
Spring 2007 5R. Smith - University of St Thomas - Minnesota Additive - Color Models - Subtractive
6
Spring 2007 6R. Smith - University of St Thomas - Minnesota Three Coloring “Formats” Gray scale (bit-mapped as a subset)Gray scale (bit-mapped as a subset) “True” Color – Hi-res Color“True” Color – Hi-res Color –What does 24-bit color mean? –What does 32-bit color mean? “Mapped” Color“Mapped” Color –A way to provide colors with fewer bits per pixel –The color of a pixel is an “index” into a matrix of larger color values – either RGB or CMY –Do you see a disadvantage here?
7
Spring 2007 7R. Smith - University of St Thomas - Minnesota Graphics in Matlab Color intensities as fractional amounts 0->1Color intensities as fractional amounts 0->1 Integer intensities as color map offsetsInteger intensities as color map offsets “image(var)” displays 2D matrix as image“image(var)” displays 2D matrix as image “imagesc(var)” scales the matrix values to fit inside the current color map. Example maps:“imagesc(var)” scales the matrix values to fit inside the current color map. Example maps: –mono: spring, summer, autumn, winter, bone, copper, gray –color: HSV, Jet, Hot, Cool, Lines
8
Spring 2007 8R. Smith - University of St Thomas - Minnesota Conway’s Game of Life Played on a 2D bit mapped matrixPlayed on a 2D bit mapped matrix –“Living” is filled in, “Dead” is blank (white) Rules for a square’s survivalRules for a square’s survival –If living and next to 2 or 3 live cells, keep living, otherwise die –If dead and next to 3 live cells, start living www.bitstorm.org/gameoflifewww.bitstorm.org/gameoflifewww.bitstorm.org/gameoflife Life3 functionLife3 function Rand(size) – yields 2d matrix of that sizeRand(size) – yields 2d matrix of that size 0.6 > rand(size) – bit map that’s not too full0.6 > rand(size) – bit map that’s not too full
9
Spring 2007 9R. Smith - University of St Thomas - Minnesota Creative Commons License This work is licensed under the Creative Commons Attribution-Share Alike 3.0 United States License. To view a copy of this license, visit http://creativecommons.org/licenses/by- sa/3.0/us/ or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.