import image.Image; import java.awt.Color; public class PA6 { // DO NOT CHANGE public static Image dummy = new Image(new Color[][]{{Color.white}}); // DO NOT CHANGE public static int luminance(Color c) { return (int)(0.2126 * c.getRed() + 0.7152 * c.getGreen() + 0.0722 * c.getBlue()); } // ------------------------------------------------------------------------ // Filters // ------------------------------------------------------------------------ public static Image grayscale(Image img) { // TODO: Implement method, replace return value and delete this comment // int height = img.getHeight(); // int width = img.getWidth(); // Color [][] imgArray = new Color [height][width]; Color [][] imgArray = img.getPixels2D(); //figure out how to grab the color within an image //luminance takes colors //getGreen, getRed, and getBlue keyword gives int value //Create color object> can do getRed method for color object //take color from each pixel of the array\ //imgArray [row][col] REPRESENTS COLOR for (int row = 0; row < img.getHeight(); ++row){ for(int col = 0; col < img.getWidth(); ++col){ Color obj = imgArray[row][col]; int red = luminance(obj); int green = luminance(obj); int blue = luminance(obj); imgArray [row][col] = new Color(red,green,blue); } Image grayItAll = new Image(imgArray); } Image grayItAll = new Image(imgArray); return grayItAll; } public static Image blend(Image img1, Image img2) { // TODO: Implement method, replace return value and delete this comment Color [][] img1Array = img1.getPixels2D(); Color [][] img2Array = img2.getPixels2D(); int height = img1.getHeight(); int width = img1.getWidth(); Color [][] newImageArray = img1.getPixels2D(); for(int row = 0; row< height; ++row){ for(int col=0; col < width; ++col){ newImageArray [row][col] = new Color((img1Array[row][col].getRed()+img2Array[row][col].getRed())/2, (img1Array[row][col].getGreen()+img2Array[row][col].getGreen())/2 , (img1Array[row][col].getBlue()+img2Array[row][col].getBlue())/2); } Image blendResult = new Image(newImageArray); } Image blendResult = new Image(newImageArray); return blendResult; } public static Image crop(Image img, int width, int height) { // TODO: Implement method, replace return value and delete this comment //2D array keywords have diferent functions //You can set the color as well as the indexes of the color Color [][]imgArray = img.getPixels2D(); Color [][] newArray = new Color[height][width]; for(int row = 0; row