Uses 3874K of libraries. Click here for Pure Java version (13446L/83K/311K).
1 | !7 |
2 | |
3 | // Actually the relationship between the white and the black part |
4 | // could be much more general. Why do they have to touch each other? |
5 | // Why do they need to have the same aspect ratio? Only the area has |
6 | // to be the same. |
7 | // |
8 | // And even that could be lifted by applying a correction factor |
9 | // (area white / area black). |
10 | // |
11 | // Finally, they can even overlap, then you'd use a factor of |
12 | // (non-overlapping white area / non-overlapping black area). |
13 | // |
14 | // No idea if these would then be called "generalized Haar features" or what |
15 | // |
16 | // The general unit returned by a Haar match should be pixels*brightness |
17 | // (value can be negative too). |
18 | // |
19 | // Result classification: |
20 | // positive = match |
21 | // 0 = non-match (indifferent/not applicable) |
22 | // negative = anti-match (Haar feature should be inverted) |
23 | |
24 | p-subst { |
25 | repeat with sleep 1 { |
26 | currentImage(newBufferedImage(200, 200, Color.gray)); |
27 | Rect r = randomRect(); |
28 | Pair<Rect> p; |
29 | if (tossCoin()) { |
30 | r.h &= ~1; // make even |
31 | p = splitRectInVerticalHalves(r); |
32 | } else { |
33 | r.w &= ~1; // make even |
34 | p = splitRectInHorizontalHalves(r); |
35 | } |
36 | if (oneInTwoChance()) p = reversePair(p); |
37 | fillRect(p.a, Color.black); |
38 | fillRect(p.b, Color.white); |
39 | quickShowImage(); |
40 | } |
41 | } |
Began life as a copy of #1006918
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, iveijnkanddl, lpdgvwnxivlt, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1009142 |
Snippet name: | Paint random Haar-like features (OK) |
Eternal ID of this version: | #1009142/19 |
Text MD5: | 02e9992b09d448fbb42edc8402be56cf |
Transpilation MD5: | d3d196a7ab7d84feec070c429bf7599b |
Author: | stefan |
Category: | javax / imaging |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-09-08 04:31:30 |
Source code size: | 1305 bytes / 41 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 529 / 703 |
Version history: | 18 change(s) |
Referenced in: | [show references] |