import java.awt.*; import java.awt.image.*; public class LinearMap { static ImageTool imTool = new ImageTool (); public static void main (String[] argv) { // Read in an image and display. Image image = imTool.readImageFile ("prof.jpg"); imTool.showImage (image, "original"); // Convert to grey scale and display. Image mappedImage = linearMap (image, 2.0, 1.0); imTool.showImage (mappedImage, "mapped image"); } static Image linearMap (Image image, double a, double b) { // Extract pixels and size. int[][][] pixels = imTool.imageToPixels (image); int numRows = pixels.length; int numCols = pixels[0].length; // Make the new pixels. int[][][] mappedPixels = new int [numRows][numCols][4]; // Almost like a copy. for (int i=0; i 255) { return 255; } return value; } }