Uses 1113K of libraries. Click here for Pure Java version (3357L/17K).
cmodule2 URecog > DynPrintLog { // returns 0, 1 or 2 int posterizeToInt(double x) { ret ifloor(clampZeroToOne(x)*3); } // returns 0, .5 or 1 double posterizeInPlace(double x) { ret posterizeToInt(x)*.5; } class Cell { // Original image and which part we are looking at IIntegralImage image; DoubleRange xClip, yClip; // color transformations in place DoubleRange[] colorClips = new[3]; *() {} // internal // make the root cell *(IIntegralImage *image) { xClip = yClip = zeroToOne(); for i to 3: colorClips[i] = zeroToOne(); } Cell copy() { new Cell c; c.image = image; c.xClip = xClip; arrayCopy(colorClips, c.colorClips); ret c; } Rect rectInImage() { ret toRect_floor(doubleRectFromRanges(xClip, yClip)); } // get color of cell double color(int channel) { double color = ii_averageBrightnessOfArea(image, rectInImage()); ret transformBetweenDoubleRanges(color, colorClips[channel], zeroToOne()); } int posterizedIntColor(int channel) { ret posterizeToInt(color(channel)); } // get sub-cells Cell[] xSplit() { Cell[] cells = new[3]; for i to 3: cells[i] = xSlice(i, i+1); ret cells; } Cell xSlice(double a, double b) { Cell c = copy(); c.xClip = transformBetweenDoubleRanges(DoubleRange(a, b), zeroToOne(), xClip); ret c; } Cell[] ySplit() { Cell[] cells = new[3]; for i to 3: cells[i] = ySlice(i, i+1); ret cells; } Cell ySlice(double a, double b) { Cell c = copy(); c.yClip = transformBetweenDoubleRanges(DoubleRange(a, b), zeroToOne(), yClip); ret c; } } }
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx
No comments. add comment
Snippet ID: | #1031919 |
Snippet name: | U [dev.] |
Eternal ID of this version: | #1031919/9 |
Text MD5: | 9c2a0b17b85afdb12fb12c8ff67b4387 |
Transpilation MD5: | d4ae873c81bac2cd260ed173a2907dd5 |
Author: | stefan |
Category: | |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-08-02 04:42:20 |
Source code size: | 1753 bytes / 77 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 167 / 280 |
Version history: | 8 change(s) |
Referenced in: | -