Libraryless. Click here for Pure Java version (4437L/25K).
1 | sclass IIVerticalSplit extends Meta implements IIntegralImage { |
2 | // y coordinate of split point |
3 | int splitPoint; |
4 | |
5 | // a and b must have same width |
6 | |
7 | // [0; splitPoint) |
8 | RegisteredReference<IIntegralImage> a = new(this); |
9 | |
10 | // [splitPoint; height) |
11 | RegisteredReference<IIntegralImage> b = new(this); |
12 | |
13 | *() {} |
14 | *(IIntegralImage img, int splitPoint) { |
15 | init(img, splitPoint); |
16 | } |
17 | |
18 | void init(IIntegralImage img, int splitPoint) { |
19 | this.splitPoint = splitPoint; |
20 | int w = img.getWidth(), h = img.getHeight(); |
21 | a.set(img.clip(0, 0, w, splitPoint)); |
22 | b.set(img.clip(0, splitPoint, w, h-splitPoint)); |
23 | } |
24 | |
25 | *(IIntegralImage img) { |
26 | int h = img.getHeight(); |
27 | if (h < 2) fail("Can't split image vertically - too small"); |
28 | init(img, h/2); |
29 | } |
30 | |
31 | *(IIntegralImage img1, IIntegralImage img2) { |
32 | a.set(img1); |
33 | b.set(img2); |
34 | splitPoint = img1.getHeight(); |
35 | } |
36 | |
37 | public int getWidth() { ret a->getWidth(); } |
38 | public simplyCached int getHeight() { ret a->getHeight()+b->getHeight(); } |
39 | |
40 | public double getIntegralValue(int x, int y, int channel) { |
41 | if (y < splitPoint) |
42 | ret a->getIntegralValue(x, y, channel); |
43 | else ret |
44 | a->getIntegralValue(x, splitPoint, channel) |
45 | + b->getIntegralValue(x, y-splitPoint, channel); |
46 | } |
47 | |
48 | public double getIntegralValue(int x, int y) { |
49 | if (y < splitPoint) |
50 | ret a->getIntegralValue(x, y); |
51 | else ret |
52 | a->getIntegralValue(x, splitPoint) |
53 | + b->getIntegralValue(x, y-splitPoint); |
54 | } |
55 | |
56 | public BufferedImage getBufferedImage() { |
57 | BufferedImage img = newBufferedImage(getWidth(), getHeight()); |
58 | var g = graphics(img); |
59 | a->drawAt(g, 0, 0); |
60 | b->drawAt(g, 0, splitPoint); |
61 | ret img; |
62 | } |
63 | } |
Began life as a copy of #1031958
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx
No comments. add comment
Snippet ID: | #1031959 |
Snippet name: | IIVerticalSplit - IIntegralImage composed of 2 vertical parts (OK) |
Eternal ID of this version: | #1031959/8 |
Text MD5: | 26e2b7fa8f11fe3d0e091147b172f7b8 |
Transpilation MD5: | 79b53662631f88216a609f64ec003778 |
Author: | stefan |
Category: | javax / image recognition |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-08-17 13:49:14 |
Source code size: | 1786 bytes / 63 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 180 / 349 |
Version history: | 7 change(s) |
Referenced in: | [show references] |