Transpiled version (5506L) is out of date.
1 | srecord noeq RawBufferedImageDistance_sameSize(BufferedImage img1, |
2 | BufferedImage img2) { |
3 | settable long stoppingValue = Int.MAX_VALUE; |
4 | int w, h; |
5 | int x, y; // where we stopped calculating |
6 | long sum; |
7 | |
8 | bool completed() { ret w != 0 && x == w && y == h; } |
9 | |
10 | long get() { |
11 | int w = this.w = img1.getWidth(), h = this.h = img1.getHeight(); |
12 | assertSameSize(img1, img2); |
13 | |
14 | var gp1 = grabbableIntPixels_fastOrSlow(img1); |
15 | var gp2 = grabbableIntPixels_fastOrSlow(img2); |
16 | |
17 | int iPixels1 = gp1.offset, iPixels2 = gp2.offset; |
18 | int[] pixels1 = gp1.data, pixels2 = gp2.data; |
19 | long sum = 0; |
20 | |
21 | for y to h: { |
22 | for x to w: { |
23 | sum += rawRGBDiff( |
24 | pixels1[iPixels1+x], |
25 | pixels2[iPixels2+x]); |
26 | |
27 | // cancel if difference out of interest range |
28 | if (sum > stoppingValue) { |
29 | this.x = x; this.y = y; |
30 | this.sum = sum; |
31 | ret sum; |
32 | } |
33 | } |
34 | |
35 | iPixels1 += gp1.scanlineStride; |
36 | iPixels2 += gp2.scanlineStride; |
37 | } |
38 | |
39 | this.x = w; this.y = h; |
40 | ret this.sum = sum; |
41 | } |
42 | } |
Began life as a copy of #1034891
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, ekrmjmnbrukm, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1034893 |
Snippet name: | RawBufferedImageDistance_sameSize - returns long (between 0 and nPixels*255*3) |
Eternal ID of this version: | #1034893/7 |
Text MD5: | 39b8962830414a8c9592f22fbcd67641 |
Author: | stefan |
Category: | javax / ocr |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-03-13 03:18:57 |
Source code size: | 1135 bytes / 42 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 144 / 235 |
Version history: | 6 change(s) |
Referenced in: | [show references] |