static IIntegralImage scaledIntegralImage(IIntegralImage img, int w) { ret scaledIntegralImage(img, w, iround(w*img.getHeight()/(double) img.getWidth())); } static IIntegralImage scaledIntegralImage(IIntegralImage img, int w, int h) { ret new IIntegralImage { int w1 = img.getWidth(), h1 = img.getHeight(); double factorX = doubleRatio(w1, w); double factorY = doubleRatio(h1, h); double areaCorrection = 1/(factorX*factorY); public int getWidth() { ret w; } public int getHeight() { ret h; } // get value for 1 channel // normal range [0; pixelCount*256) // TODO: test public double getIntegralValue(int x, int y, int channel) { double x2 = (x+1)*factorX-1; double y2 = (y+1)*factorY-1; double val = img.getIntegralValue(x2, y2, channel); ifdef scaledIntegralImage_debug printVars scaledIntegralImage(+x, +y, +x2, +y2, +val, val2 := val*areaCorrection); endifdef ret val*areaCorrection; } }; }