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:
/** * 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?