Libraryless. Click here for Pure Java version (5333L/35K).
// assumes coordinates are in range static RGB ii_averageColorOfArea(IntegralImage img, int x1, int y1, int x2, int y2) { if (img == null) null; int area = (x2-x1)*(y2-y1); int r = integralImage_sumRect(img, x1, y1, x2, y2, 0)/area; int g = integralImage_sumRect(img, x1, y1, x2, y2, 1)/area; int b = integralImage_sumRect(img, x1, y1, x2, y2, 2)/area; ret RGB(rgbInt(r, g, b)); } static RGB ii_averageColorOfArea(IntegralImage img, Rect r) { ret r == null ? null : ii_averageColorOfArea(img, r.x, r.y, r.x2(), r.y2()); } // later TODO: sub-pixel accuracy static RGB ii_averageColorOfArea(IntegralImage img, DoubleRect r) { ret ii_averageColorOfArea(img, toRect(r)); }
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: | 278 / 392 |
Version history: | 4 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) #1025275 - ii_getPixel |