Libraryless. Click here for Pure Java version (4640L/26K).
// is it a split? is it a join? depends on your view sclass IIHorizontalSplit extends Meta implements IIntegralImage { // x coordinate of split point // - isn't this just a.getWidth()? int splitPoint; // a and b must have same height // [0; splitPoint) RegisteredReference<IIntegralImage> a = new(this); // [splitPoint; width) RegisteredReference<IIntegralImage> b = new(this); *() {} *(IIntegralImage img) { int w = img.getWidth(); if (w < 2) fail("Can't split image horizontally - too small"); init(img, w/2); } *(IIntegralImage img, int splitPoint) { init(img, splitPoint); } *(IIntegralImage img1, IIntegralImage img2) { a.set(img1); b.set(img2); splitPoint = img1.getWidth(); } void init(IIntegralImage img, int splitPoint) { this.splitPoint = splitPoint; int w = img.getWidth(), h = img.getHeight(); a.set(img.clip(0, 0, splitPoint, h)); b.set(img.clip(splitPoint, 0, w-splitPoint, h)); } public simplyCached int getWidth() { ret a->getWidth()+b->getWidth(); } public int getHeight() { ret a->getHeight(); } public double getIntegralValue(int x, int y, int channel) { if (x < splitPoint) ret a->getIntegralValue(x, y, channel); else ret a->getIntegralValue(splitPoint, y, channel) + b->getIntegralValue(x-splitPoint, y, channel); } public double getIntegralValue(int x, int y) { if (x < splitPoint) ret a->getIntegralValue(x, y); else ret a->getIntegralValue(splitPoint, y) + b->getIntegralValue(x-splitPoint, y); } public BufferedImage getBufferedImage() { BufferedImage img = newBufferedImage(getWidth(), getHeight()); var g = graphics(img); a->drawAt(g, 0, 0); b->drawAt(g, splitPoint, 0); ret img; } IIntegralImage a() { ret a!; } IIntegralImage b() { ret b!; } void setA(IIntegralImage a) { this.a.set(a); } void setB(IIntegralImage b) { this.b.set(b); } }
Began life as a copy of #1031959
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx
No comments. add comment
Snippet ID: | #1031964 |
Snippet name: | IIHorizontalSplit - IIntegralImage composed of 2 horizontal parts (OK) |
Eternal ID of this version: | #1031964/9 |
Text MD5: | 5d172666eec330c400a528247f65ea36 |
Transpilation MD5: | c43df0bb97b9f28fda64cef6ba32e6b0 |
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:48:23 |
Source code size: | 2046 bytes / 69 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 175 / 339 |
Version history: | 8 change(s) |
Referenced in: | [show references] |