Libraryless. Click here for Pure Java version (11576L/68K).
1 | // forgets sub-pixels |
2 | // nearest neighbor, basically |
3 | // TODO: fix? |
4 | sclass TruncatedIBWIntegralImage > Meta is IBWIntegralImage { |
5 | IBWIntegralImage img; |
6 | int w, h; |
7 | |
8 | *(IBWIntegralImage *img) { |
9 | w = img.getWidth(); |
10 | h = img.getHeight(); |
11 | } |
12 | |
13 | public int getWidth() { ret w; } |
14 | public int getHeight() { ret h; } |
15 | |
16 | // normal range [0; pixelCount*256) |
17 | public double getIIValue(dbl x, dbl y) { |
18 | int xFloor = ifloor(x), yFloor = ifloor(y); |
19 | |
20 | // get value at top left corner of pixel |
21 | double val = img.getIIValue(xFloor, yFloor); |
22 | |
23 | // at integer coordinate? done |
24 | if (xFloor == x && yFloor == y) |
25 | ret val; |
26 | |
27 | double xFrac = x-xFloor, yFrac = y-yFloor; |
28 | |
29 | // at non-integer coordinate, perform subpixel calculation |
30 | double area = xFrac*yFrac; |
31 | double pixelColor = img.getPixelBrightness(xFloor+1, yFloor+1); |
32 | |
33 | ret val+area*pixelColor; |
34 | } |
35 | } |
Began life as a copy of #1033566
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1033569 |
Snippet name: | TruncatedIBWIntegralImage [forget sub-pixels] |
Eternal ID of this version: | #1033569/11 |
Text MD5: | 1e9a0ed0fa951c9cbc45f0ea582a525f |
Transpilation MD5: | b71a7af2293b9166b66321c519350fb1 |
Author: | stefan |
Category: | javax / imaging |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-01-05 02:03:01 |
Source code size: | 942 bytes / 35 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 211 / 329 |
Version history: | 10 change(s) |
Referenced in: | [show references] |