Libraryless. Click here for Pure Java version (12542L/73K).
1 | sinterface IBWIntegralImage extends MakesBufferedImage, IBWImage, IMeta { |
2 | public int getWidth(); |
3 | public int getHeight(); |
4 | |
5 | // implement one of the following two methods! |
6 | |
7 | // integer version (both coordinates & brightnesses are ints) |
8 | public default int getIIValue(int x, int y) { |
9 | ret iround(getIIValue((double) x, (double) y)); |
10 | } |
11 | |
12 | // floating point version (both coordinates & brightnesses are doubles) |
13 | public default double getIIValue(double x, double y) { |
14 | ret getIIValue(ifloor(x), ifloor(y)); |
15 | } |
16 | |
17 | // 0.0 to 255.0 |
18 | default public double getPixelAverage(int x1, int y1, int x2, int y2) { |
19 | int area = (x2-x1)*(y2-y1); |
20 | ret doubleRatio(getPixelSum(x1, y1, x2, y2), area); |
21 | } |
22 | |
23 | default public dbl getPixelAverage(dbl x1, dbl y1, dbl x2, dbl y2) { |
24 | dbl area = (x2-x1)*(y2-y1); |
25 | ret doubleRatio(getPixelSum(x1, y1, x2, y2), area); |
26 | } |
27 | |
28 | default public double getPixelAverage(Rect r) { |
29 | ret getPixelAverage(r.x, r.y, r.x2(), r.y2()); |
30 | } |
31 | |
32 | default public int getPixelSum(int x1, int y1, int x2, int y2) { |
33 | ret bwIntegralImage_sumRect(this, x1, y1, x2, y2); |
34 | } |
35 | |
36 | default public double getPixelSum(double x1, double y1, double x2, double y2) { |
37 | ret bwIntegralImage_sumRect(this, x1, y1, x2, y2); |
38 | } |
39 | |
40 | default public int getPixelBrightness aka getInt(int x, int y) { |
41 | ret getPixelSum(x, y, x+1, y+1); |
42 | } |
43 | |
44 | default public int getPixelBrightness(Pt p) { ret getPixelBrightness(p.x, p.y); } |
45 | |
46 | public default BufferedImage getBufferedImage() { |
47 | //ret scaleDownUsingIntegralImageBW(this, w).getBufferedImage(); |
48 | ret grayImageFromIBWIntegralImage(this); |
49 | } |
50 | |
51 | // implementing IBWImage |
52 | public default float getFloatPixel(int x, int y) { |
53 | ret getPixelBrightness(x, y)/255f; |
54 | } |
55 | } |
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1027205 |
Snippet name: | IBWIntegralImage |
Eternal ID of this version: | #1027205/28 |
Text MD5: | 99c4f06068b996d43ae2606eaf3ff0cf |
Transpilation MD5: | 8e3b942401575e1865a6af7c26d6907e |
Author: | stefan |
Category: | javax / image recognition |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-02-06 21:11:38 |
Source code size: | 1814 bytes / 55 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 369 / 856 |
Version history: | 27 change(s) |
Referenced in: | [show references] |