Score Range | Count | ||||
Count: | 101 | 100: | 2 | ||
Max: | 100 x2 | 90's: | 13 | ||
Min: | 20 | 80's: | 16 | ||
Ave: | 65.93 | 70's: | 15 | ||
Median: | 68.00 | 60's: | 17 | ||
St. Dev: | 20.69 | 50's: | 15 | ||
40's: | 10 | ||||
30's: | 7 | ||||
20's: | 6 |
public static Picture q21 ( Picture p ) { int x; int y; // loop for all of the columns in the picture for ( x = 0 ; x < p.getWidth() ; x++ ) { // access column x in the picture for ( y = 0 ; y < p.getHeight() ; y++ ) { Pixel pix = p.getPixel(x, y); // manipulate pix as desired int r = pix.getRed(); int g = pix.getGreen(); int b = pix.getBlue(); int grayAmount = (int)(r*0.299 + g*0.587 + b*0.114); if ( grayAmount < 85 ) // 255 / 3 is 85 ==> BLUE { pix.setColor (Color.BLUE); } else if ( grayAmount < 170 ) // 255 * 2 / 3 is 170 ==> GREEN { pix.setColor (Color.GREEN); } else // ==> CYAN { pix.setColor (Color.CYAN); } } } return p; }Question 22.
public static Picture q22 ( Picture p ) { Picture result; int width = p.getWidth(); int height = p.getHeight(); result = new Picture ( width * 2, height ); int x; int y; // loop for all of the columns in the picture for ( x = 0 ; x < width ; x++ ) { // access column x in the picture for ( y = 0 ; y < height ; y++ ) { Pixel pix = p.getPixel(x, y); Color c1 = pix.getColor(); // copy the first pixel position int resultX = x; int resultY = y; Pixel resultPix = result.getPixel ( resultX, resultY ); resultPix.setColor ( c1 ); // copy into the second pixel position resultX = width + width-1 - x; resultY = y; resultPix = result.getPixel ( resultX, resultY ); resultPix.setColor ( c1 ); } } return result; }-- Main.troy - 2015-04-24
Copyright 2016 The Board of Trustees of the University of Illinois.webmaster@cs.uic.edu |
WISEST Helping Women Faculty Advance Funded by NSF | ![]() | ![]() |