Write a static method blur(double[][] picture) that you could use on a part of a picture file to obscure a detail such as a person’s face or a license plate number. This method computes the weighted averages of the values in picture and returns them in a new two-dimensional array. To find a weighted average of a group of numbers, you count some of them more than others. Thus, you multiply each item by its weight, add these products together, and divide the result by the sum of the weights.
For each element in picture, compute the weighted average of the element
and its immediate neighbors. Store the result in a new two-dimensional array in the same position that the element occupies in picture. This new array is the one the method returns. The neighbors of an element in picture can be above, below, to the left of,
and to the right of it, either vertically, horizontally, or diagonally. So each weighted average in the new array will be a combination of up to nine values from the array picture. A corner value will use only four values: itself and three neighbors. An edge value will use only six values: itself and five neighbors. But an interior value will use nine values: itself and eight neighbors. So you will need to treat the corners and edges separately from the other cells.
See the code in TwoDArrayMethods.java.
You might also like to view...
When two different sections of a document are displayed at the same time, the two windows are separated by a(n) ________ bar
Fill in the blank(s) with correct word
A ____ lets the customer determine whether an individual supplier is carrying out the practices that the customer considers necessary to ensure security.
A. baseline profile B. custom profile C. standard profile D. reference profile