Libraryless. Click here for Pure Java version (5177L/30K).
1 | // Another minor generalization over Haar features allowing multiple |
2 | // black and white areas at the same time |
3 | |
4 | // (It's only actually different from combining multiple Haar features |
5 | // when l(rBlack) != l(rWhite).) |
6 | // |
7 | // Result classification, as always: |
8 | // |
9 | // positive = match |
10 | // 0 = non-match (indifferent/not applicable) |
11 | // negative = anti-match (inverted Haar feature found) |
12 | |
13 | srecord MultiHaar(IIntegralImage img, L<DoubleRect> rBlack, L<DoubleRect> rWhite) { |
14 | double get() { |
15 | double blackArea = totalAreaOfDoubleRects(rBlack); |
16 | double whiteArea = totalAreaOfDoubleRects(rWhite); |
17 | |
18 | double whiteSum = 0, blackSum = 0; |
19 | for (DoubleRect r : rWhite) whiteSum += img.pixelSum(r); |
20 | for (DoubleRect r : rBlack) blackSum += img.pixelSum(r); |
21 | |
22 | ret (doubleRatio(whiteSum, whiteArea) - doubleRatio(blackSum, blackArea))/255.0; |
23 | } |
24 | } |
Began life as a copy of #1032466
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx
No comments. add comment
Snippet ID: | #1032471 |
Snippet name: | MultiHaar - even more generalized Haar-like feature with m black and n white areas |
Eternal ID of this version: | #1032471/4 |
Text MD5: | 4d6b8fc313f06c7cda2fac0e76fd3404 |
Transpilation MD5: | 238276c565b1e09b10d7cd50d69d2e51 |
Author: | stefan |
Category: | javax / imaging |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-09-09 22:34:11 |
Source code size: | 882 bytes / 24 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 153 / 285 |
Version history: | 3 change(s) |
Referenced in: | [show references] |