Review 1 What is binary? What kinds of data can be represented in binary? What about images? 2-1 How do we turn a scene into something we can store in a computer? What about images? 2-2 How do we turn a scene into something we can store in a computer? Need a way to represent colors in binary Need a way to indicate the sequence of colors that make up a picture
Bitmap Representation 3-1 Divide an image into a grid Pick the average color in each cell (pixel) Remember that color Bitmap Representation 3-2 Divide an image into a grid Pick the average color in each cell (pixel) Remember that color Remember Average Pixel Color 4-1
Remember Average Pixel Color 4-2 Remember Average Pixel Color 4-3 Pixels are very small! 5
6 Exploring pictures with JES First, get a picture into a variable: mypicture = makepicture (pickafile()) Display with: explore (mypicture) 7 Map coordinates A B C D E 1 Consist of a row and column Cleveland is in D4 F G H I J 7 69 50 30 28 29 39 32 57 12 2 54 37 66 70 52 20 8 45 41 3 55 68 3 9 62 46 16 47 1 2 51 61 56 17 48 11 5 42 31 4 25 23 43 18 38 21 14 4 26 15 36 10 65 33 6 64 40 24 53 19 13 44 60 34 59 35 58 22 49 5 67 63 Directions to Mount Holyoke College Consists of a row and column By Car From the south: North on I-91 to Route 202 (Exit 16, Holyoke/South Hadley). North on 202 through Holyoke, across the Connecticut River, and around the rotary to the South Hadley Center-Amherst exit; Route 116 north for 2.5 miles. From the north: South on I-91 to Exit 16; follow directions above. From the Mass Turnpike, east or west: Exit 5 (Holyoke/ Chicopee) to Route 33 for five miles; right onto 116; 1.5 miles north to MHC. 27 By Train Amtrak station in Springfield: www.amtrak.com. Mailing address Mount Holyoke College 50 College Street South Hadley, MA 01075 By Air Bradley International Airport, serving Hartford, Connecticut, and Springfield, Massachusetts, is 35 miles south of Mount Holyoke on I-91. For van/car service from the airport: www.bradleyairport.com/transport. www.mtholyoke.edu By Bus Peter Pan service from Boston and New York City to South Hadley with transfers in Springfield: www.peterpanbus.com. Pixel Coordinates 8 Main switchboard 413-538-2000 X is the column Y is the row 0, 0 is at the top, left corner Identify exactly one pixel
Pre-defined pixel functions 9-1 getpixel ( <picture>, <column>, <row>) - returns a pixel getpixels ( <picture> ) - returns an array of all the pixels Pre-defined pixel functions 9-2 getpixel ( <picture>, <column>, <row>) - returns a pixel getpixels ( <picture> ) - returns an array of all the pixels Terminology: An array is a list of values Calling getpixel 10-1
Calling getpixel 10-2 Calling getpixel 10-3 What is a Color? 11 RGB - Red Green Blue 3 light sources, one of each color Specify how intense each light source should be Values range between 0 and 255 Example: Red = 255, Green = 0, Blue = 0 Example: Red = 129, Green = 202, Blue = 60 Example: Red = 245, Green = 248, Blue = 34 What is black, white, gray?
Color Chooser 12 How Many Shades of Red are There? 13-1 How Many Shades of Red are There? 13-2 256 Red
How Many Combinations of Red and Green are There? 14-1 How Many Combinations of Red and Green are There? 14-2 256 Red * 256 Green = 65,536 Red/Green combinations How Many RGB Colors are There? 15-1 256 Red * 256 Green * 256 Blue = 16,777,216 Red/Green/Blue combinations
How Many RGB Colors are There? 15-2 256 Red * 256 Green * 256 Blue = 16,777,216 Red/Green/Blue combinations My display only has 2880 * 1800 = 5,184,000 pixels!! There are not enough pixels on my screen to display all the colors at one time! 16 A magnified view of an RGB display Calling getpixels 17-1 getpixels returns an array big enough to hold each pixel of an image Array contains all the pixels of the first row, followed by all the pixels of the second row, etc. How long would it be? How much memory does the array use?
Calling getpixels 17-2 getpixels returns an array big enough to hold each pixel of an image Array contains all the pixels of the first row, followed by all the pixels of the second row, etc. How long would it be? How much memory does the array use? Summary of new functions 18 getpixel ( <picture>, <column>, <row>) - returns a pixel getpixels ( <picture> ) - returns an array of all the pixels getwidth ( <picture> ) - returns the number of columns of pixels in the picture getheight ( <picture> ) - returns the number of rows of pixels in the picture Summary of Digital Representations 19 ASCII and Unicode are two binary encodings for text. RGB is a binary encoding for color Images consist of a 2D grid of pixels, each with a unique color