1 | static Pair<BWImage, S> unsubtitle(BWImage img) { |
2 | int h = img.getHeight(), y1 = h-12; |
3 | if (y1 < 0) null; |
4 | int w = img.getWidth(); |
5 | int x1 = w, x2 = 0; |
6 | for (int x = 0; x < w; x++) |
7 | if (img.getPixel(x, y1) < 0.5) { |
8 | x1 = min(x1, x); |
9 | x2 = max(x2, x+1); |
10 | if (img.getPixel(x, h-1) >= 0.5) null; |
11 | } else |
12 | if (img.getPixel(x, h-1) < 0.5) null; |
13 | |
14 | if (x1 > x2) null; |
15 | BWImage sub = img.clip(x1-1, y1, x2-x1+2, h-y1); |
16 | //showBWImage(sub); |
17 | S text = imageToUtf(sub); |
18 | ret pair(img.clip(0, 0, w, y1), text); |
19 | } |
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1004644 |
Snippet name: | unsubtitle |
Eternal ID of this version: | #1004644/1 |
Text MD5: | b6e5f3f8b97d58cf4ac07ebc2f452b7a |
Author: | stefan |
Category: | javax / images |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-08-24 19:50:53 |
Source code size: | 560 bytes / 19 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 557 / 570 |
Referenced in: | [show references] |