static float[] ocr_leftProfile_scaled(int n, double stopAtRatio, BWImage img) { int w = img.getWidth(); int stopAt = min(w-1, iround(img.getWidth()*stopAtRatio)), h = img.getHeight(); float[] out = new float[n]; for y to n: { int realY = ifloor(y*h/n); int x = 0; while (x <= stopAt && img.getPixel(x, y) > 0.5f) ++x; out[y] = iround(x/w); } ret out; }