Libraryless. Click here for Pure Java version (5333L/35K).
1 | // assumes coordinates are in range |
2 | static RGB ii_averageColorOfArea(IntegralImage img, int x1, int y1, int x2, int y2) { |
3 | if (img == null) null; |
4 | int area = (x2-x1)*(y2-y1); |
5 | int r = integralImage_sumRect(img, x1, y1, x2, y2, 0)/area; |
6 | int g = integralImage_sumRect(img, x1, y1, x2, y2, 1)/area; |
7 | int b = integralImage_sumRect(img, x1, y1, x2, y2, 2)/area; |
8 | ret RGB(rgbInt(r, g, b)); |
9 | } |
10 | |
11 | static RGB ii_averageColorOfArea(IntegralImage img, Rect r) { |
12 | ret r == null ? null : ii_averageColorOfArea(img, r.x, r.y, r.x2(), r.y2()); |
13 | } |
14 | |
15 | // later TODO: sub-pixel accuracy |
16 | static RGB ii_averageColorOfArea(IntegralImage img, DoubleRect r) { |
17 | ret ii_averageColorOfArea(img, toRect(r)); |
18 | } |
Began life as a copy of #1025228
download show line numbers debug dex old transpilations
Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1025257 |
Snippet name: | ii_averageColorOfArea |
Eternal ID of this version: | #1025257/5 |
Text MD5: | d6b545a601d814489e46d2c807c2d7ea |
Transpilation MD5: | 9364784123a0078b99ea01c53d010892 |
Author: | stefan |
Category: | javax / integral images |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-09-29 14:49:55 |
Source code size: | 703 bytes / 18 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 277 / 391 |
Version history: | 4 change(s) |
Referenced in: | [show references] |