// not scaled static IBWImage virtualScaledIntegralImageBW(BWIntegralImage img) { ret virtualScaledIntegralImageBW(img, img.getWidth(), img.getHeight()); } static IBWImage virtualScaledIntegralImageBW(BWIntegralImage img, int w) { ret virtualScaledIntegralImageBW(img, w, iround(w*img.h/(double) img.w)); } static IBWImage virtualScaledIntegralImageBW(BWIntegralImage img, int w, int h) { ret new IBWImage { int w1 = img.w, h1 = img.h; public int getWidth() { ret w; } public int getHeight() { ret h; } public float getFloatPixel(int x, int y) { int x1 = x*w1/w, x2 = max(x1+1, (x+1)*w1/w); int y1 = y*h1/h, y2 = max(y1+1, (y+1)*h1/h); int area = (x2-x1)*(y2-y1); int pixel = bwIntegralImage_sumRect(img, x1, y1, x2, y2)/area; ret pixel/255f; } }; }