Exercise 3


In this exercise, you will explore some transformations on images and get some practice working with 2D arrays. Essentially, you will read in an input image and construct a "result" image from the input image. To construct the (i,j)-th pixel in the result image, you will take a weighted average of the intensity values of the (i,j-th pixel in the original image and the corresponding intensities of the pixels around the (i,j)-th pixel of the original image.

Since each pixel, except for those at the borders, has 8 neighboring pixels and itself, we need a total of 9 weights. These weights are themselves specified in a 3 x 3 array. This smaller array is called a kernel in the image processing jargon. For example, consider the kernel

        double[][] someKernel = {
            {0.1, 0.2, 0.3},
            {0.1, 0.5, 0.2},
            {0.1, -1, -0.5}
        };
  
Now, suppose we are computing the Red pixel intensity for pixel (25,53), i.e., the pixel in row 25, column 53 of the result. This is what we do:

Thus, the goal of the exercise is to do this computation for an entire image and return the result image.

To get started:

Things to note:

Submission:

What else is due: