Question: We will determine brightness as the point (i,j) in the x by y image where the sum of red[i][j], green[i][j] and blue[i][j] is the greatest.
We will determine brightness as the point (i,j) in the x by y image where the sum of red[i][j], green[i][j] and blue[i][j] is the greatest.
The body calls the method brightSpot() and based on the input, prints out the following:
"The brightest spot in the image is at position (i,j)"
The brightSpot() method will take the following parameters:
three x by y integer arrays, which we will call red, green and blue to represent the red, green and blue present in the image.
Processing
Based on the definition of brightness given above, the method will determine the brightest spot (i,j) in the image.
Output
The brightSpot() method will return an integer array containing the brightest spot (i,j).

import java.util.*;
public class Problem {
// PLEASE START YOUR METHOD HERE
// *********************************************************
// *********************************************************
//PLEASE END YOUR METHOD HERE
public static void main( String [] args ) {
Scanner in = new Scanner( System.in );
int height, width;
//Get picture height & width
height = in.nextInt();
width = in.nextInt();
//Set up image pixel arrays
int[][] red = new int[height][width];
int[][] green = new int[height][width];
int[][] blue = new int[height][width];
//Read in red values
for (int i=0; i
for (int j=0; j
red[i][j] = in.nextInt();
}
}
//Read in blue values
for (int i=0; i
for (int j=0; j
green[i][j] = in.nextInt();
}
}
//Read in green values
for (int i=0; i
for (int j=0; j
blue[i][j] = in.nextInt();
}
}
int[] brightest = brightSpot(red, blue, green);
System.out.println("The brightest spot in the image is at position ("+brightest[0]+","+brightest[1]+")");
in.close();
System.out.print("END OF OUTPUT");
}
}
Sample brightSpot() method input 11, 12, 2, 0, 3, [1,1} {2,2} {1,1), Sample brightSpot() method return 0, 1 Samplemain) method output The brightest spot in the image is at position (0,1)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
