// one channel static int integralImage_sumRect(IntegralImage img, int x1, int y1, int x2, int y2, int channel) { int bottomLeft = img.get(x1-1, y2-1, channel); int bottomRight = img.get(x2-1, y2-1, channel); int topLeft = img.get(x1-1, y1-1, channel); int topRight = img.get(x2-1, y1-1, channel); ret bottomRight+topLeft-topRight-bottomLeft; } // sum all channels static int integralImage_sumRect(IntegralImage img, int x1, int y1, int x2, int y2) { ret integralImage_sumRect(img, x1, y1, x2, y2, 0) + integralImage_sumRect(img, x1, y1, x2, y2, 1) + integralImage_sumRect(img, x1, y1, x2, y2, 2); }