static double iiSumRec(double[][[] ii, Rect r) { double bottomLeft = ii[r.y2()-1][r.x1-1]; double bottomRight = ii[r.y2()-1][r.x2()-1]; double topLeft = ii[r.y1-1][r.x1-1]; double topRight = ii[r.y1-1][r.x2()-1]; double lShape = bottomRight-topLeft; double topRightSegment = topRight-topLeft; double bottomLeftSegment = bottomLeft-topLeft; ret -(lShape-topRightSegment-bottomLeftSegment); }