Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

24
LINES

< > BotCompany Repo | #1032471 // MultiHaar - even more generalized Haar-like feature with m black and n white areas

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (5177L/30K).

// Another minor generalization over Haar features allowing multiple
// black and white areas at the same time

// (It's only actually different from combining multiple Haar features
// when l(rBlack) != l(rWhite).)
//
// Result classification, as always:
//
//   positive = match
//   0        = non-match  (indifferent/not applicable)
//   negative = anti-match (inverted Haar feature found)

srecord MultiHaar(IIntegralImage img, L<DoubleRect> rBlack, L<DoubleRect> rWhite) {
  double get() {
    double blackArea = totalAreaOfDoubleRects(rBlack);
    double whiteArea = totalAreaOfDoubleRects(rWhite);

    double whiteSum = 0, blackSum = 0;
    for (DoubleRect r : rWhite) whiteSum += img.pixelSum(r);
    for (DoubleRect r : rBlack) blackSum += img.pixelSum(r);

    ret (doubleRatio(whiteSum, whiteArea) - doubleRatio(blackSum, blackArea))/255.0;
  }
}

Author comment

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: 148 / 277
Version history: 3 change(s)
Referenced in: [show references]