CS 101 - 10/4/11 Picture Manipulation: Chapter 4, 5, 6 A picture is a matrix (2D array) of pixels A pixel is a PIcture ELement that contains: X and Y coordinate of the location in the picture The RED amount, The GREEN amount and The BLUE amount of color at the position Each color will be represented by a value from 0 to 255. 0 => no amount of that color 255 => maximum amount of that color RGB (0, 255, 127) = color between Green and Cyan RGB (0,0,0) => Black RGB (255, 255, 255) => White RGB (255, 0, 0) => Red RGB (0,255,0) => Green RGB (255, 255, 0) => Yellow The value from 0 to 255 are represented by an 8 bit binary number (or 1 byte) 3 MegaByte image => about 1 million pixels 1024 x 1024 x 3 = 3 MegaBytes For Loop: alternative to the while loop xPos = 0; While ( xPos < width ) { // do something xPos = xPos + 1; } A while loop has 3 parts: initialization: xPos = 0 condition: xPos < width increment: xPos = xPos + 1 The 4th part is the Body, which does the intended task A for loop attempts to simplify the while by combining the initialization, condition and increment onto a single statement. for ( xPos = 0 ; xPos < width ; xpos = xPos + 1 ) { // do something }