Libraryless. Click here for Pure Java version (11384L/64K).
1 | sclass G22MakeMaskCorrelationMatrix is MakesBufferedImage {
|
2 | settable long[][] imagesH; |
3 | settable long[][] imagesW; |
4 | |
5 | // size w()*h(), every entry is a pixel diff count |
6 | gettable int[] matrix; |
7 | |
8 | selfType images(long[][] images) {
|
9 | ret imagesW(images).imagesH(images); |
10 | } |
11 | |
12 | selfType images(L<long[]> images) {
|
13 | ret images(toArray(long[].class, images)); |
14 | } |
15 | |
16 | public int w() { ret imagesH.length; }
|
17 | public int h() { ret imagesW.length; }
|
18 | |
19 | int maxPixelDiff() { ret l(first(imagesW))*64; }
|
20 | |
21 | bool symmetrical() { ret imagesW == imagesH; }
|
22 | |
23 | run {
|
24 | int w = w(), h = h(); |
25 | var matrix = this.matrix = new int[w*h]; |
26 | int i = 0; |
27 | if (symmetrical()) |
28 | for y to h: {
|
29 | long[] imageH = imagesH[y]; |
30 | // mirror along diagonal |
31 | int x = 0, i2 = y; |
32 | for (; x < y; x++, i2 += w) |
33 | matrix[i++] = matrix[i2]; |
34 | for (; x < w; x++) |
35 | matrix[i++] = countDifferingBits(imageH, imagesW[x]); |
36 | } |
37 | else |
38 | for y to h: {
|
39 | long[] imageH = imagesH[y]; |
40 | for x to w: |
41 | matrix[i++] = countDifferingBits(imageH, imagesW[x]); |
42 | } |
43 | } |
44 | |
45 | FloatBWImage get() {
|
46 | if (matrix == null) run(); |
47 | int w = w(), h = h(); |
48 | float max = maxPixelDiff(); |
49 | ret floatBWImageFromFunction(w, h, |
50 | (x, y) -> 1f-matrix[y*w+x]/max); |
51 | } |
52 | |
53 | public BufferedImage getBufferedImage() { ret toBufferedImage (get()); }
|
54 | } |
download show line numbers debug dex old transpilations
Travelled to 2 computer(s): elmgxqgtpvxh, mqqgnosmbjvj
No comments. add comment
| Snippet ID: | #1036057 |
| Snippet name: | G22MakeMaskCorrelationMatrix |
| Eternal ID of this version: | #1036057/10 |
| Text MD5: | 3f3113d941f0911fa73a62672fd00446 |
| Transpilation MD5: | 1216d62e47d1d814ac1c502ab74a010c |
| Author: | stefan |
| Category: | javax / gazelle 22 |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2022-09-03 03:50:25 |
| Source code size: | 1464 bytes / 54 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 644 / 780 |
| Version history: | 9 change(s) |
| Referenced in: | [show references] |