How come the mean is 7?

• January 23rd, 2012, 01:28 AM
IAmHere
How come the mean is 7?
How do I calculate the mean?
The answer for this case is 7.
Why?

My assignment is here(if you want to know the question but I don't think you need it to answer "my" question):
http://www.cse.yorku.ca/course/2011/...201/Q2/Q2.html

The following is the tester class:

Code :

/**
* Tests the IntegralImage class.
*/
public class testIntegralImage {

public static void main(String[] args) {
int[][] image1 = {{1, 2, 3},
{4, 5, 6},
{7, 8, 9}};  // a 2d array. three rows, three columns.
int top,bottom,left,right;
double mean;

IntegralImage integralImage1;
top = 1;
bottom = 2;
left = 1;
right = 2;

try {
integralImage1 = new IntegralImage(image1);
} catch (InvalidImageException iix) {
System.out.println("Invalid Image Exception");
return;
}
try {
mean = integralImage1.meanSubImage(top,bottom,left,right);      //should be 7.0
System.out.println("The mean of the subimage from ("+top+","+left+") to ("+bottom+","+right+") is "+mean);
} catch (InvalidSubImageIndexException isiix)
{
System.out.println("Invalid SubImage Index Exception");
}

}
}

I'm having trouble understanding the question. I think you have to look at the 2d array and calculate the mean, given the top, left, bottom and right. How do you get 7 from this?
• January 23rd, 2012, 08:45 AM
KevinWorkman
Re: How come the mean is 7?
Quote:

I'm having trouble understanding the question. I think you have to look at the 2d array and calculate the mean, given the top, left, bottom and right. How do you get 7 from this?

The program description explains pretty clearly how to calculate the mean, and 7 is the correct answer in this case. What do you think the answer should be?