!7 // Actually the relationship between the white and the black part // could be much more general. Why do they have to touch each other? // Why do they need to have the same aspect ratio? Only the area has // to be the same. // // And even that could be lifted by applying a correction factor // (area white / area black). // // Finally, they can even overlap, then you'd use a factor of // (non-overlapping white area / non-overlapping black area). // // No idea if these would then be called "generalized Haar features" or what // // The general unit returned by a Haar match should be pixels*brightness // (value can be negative too). // // Result classification: // positive = match // 0 = non-match (indifferent/not applicable) // negative = anti-match (Haar feature should be inverted) p-subst { repeat with sleep 1 { currentImage(newBufferedImage(200, 200, Color.gray)); Rect r = randomRect(); Pair p; if (tossCoin()) { r.h &= ~1; // make even p = splitRectInVerticalHalves(r); } else { r.w &= ~1; // make even p = splitRectInHorizontalHalves(r); } if (oneInTwoChance()) p = reversePair(p); fillRect(p.a, Color.black); fillRect(p.b, Color.white); quickShowImage(); } }