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