CS 111 - 10/7/14 First - No, the exams are yet finished being graded. Pictures - has a width - has a height - has a name - has width * height pixels each pixel - has a color each color -has a red amount/level -has a green amount/level -has a blue amount/level We will work with/figure out/understand different algorithms that allow us to manipulate pictures The upper left corner of the picture contains pixel (0, 0) Assume a picture has width of 300 pixels and height of 200 pixels, What is the pixel coordinates of the pixel in the lower right corner? The column number is the X coordinate (listed first) The row number is the Y coordinate (listed dsecond) ( ColumnNumber, RowNumber ) one amnswer: (300, 200) but this is wrong correct answer: (299, 199) When I set up a loop to iterate through all of the columns, the code is as follows: Picture p = new Picture (filename) ; int width = p.getWidth(); int xIndex = 0; while ( xIndex < width ) { // do whatever I need to column number xIndex xIndex = xIndex + 1; } Expand the above code to access every pixel in each column Picture p = new Picture (filename) ; int width = p.getWidth(); int height = p.getHeight(); int xIndex = 0; while ( xIndex < width ) { // do whatever I need to column number xIndex // access each pixel in this column int yIndex = 0; while ( yIndex < height ) { // access the pixel at coordinate // (xIndex, yIndex) Pixel pix = p.getPixel (xIndex, yIndex); yIndex = yIndex + 1; } xIndex = xIndex + 1; } ------------------------------------------ The make a picture "black and white", we are really making it a grayscale picture. a gray color has the same values for red, for green and for blue. new Color ( 34, 34, 34); When we make a picture black and white, we change each pixel the the gray color that best represents the original color of the pixel. If the pixel has color value of: 54, 10, 47 the gray color should be dark If the pixel has color value of: 254, 210, 247 the gray color should be bright One way is to average the original values of red, green and blue to get the "gray amount"