Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

12
LINES

< > BotCompany Repo | #1024735 // ocr_leftProfile_scaledTo127

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (2600L/16K).

static byte[] ocr_leftProfile_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(x, realY) > 0.5f) ++x;
    out[y] = (byte) iround(x*127.0/stopAt);
  }
  ret out;
}

Author comment

Began life as a copy of #1024733

download  show line numbers  debug dex  old transpilations   

Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1024735
Snippet name: ocr_leftProfile_scaledTo127
Eternal ID of this version: #1024735/9
Text MD5: 80cbf27fe9c2729194e45064e57a96e6
Transpilation MD5: 8bb470cdd628d5343405e890f41c8365
Author: stefan
Category: javax / imaging
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-08-24 15:37:55
Source code size: 399 bytes / 12 lines
Pitched / IR pitched: No / No
Views / Downloads: 248 / 342
Version history: 8 change(s)
Referenced in: [show references]