/// <summary>
/// Sets the scale and weight of a Haar-like rectangular feature container.
/// </summary>
///
public void SetScaleAndWeight(float scale, float weight)
{
// manual loop unfolding
if (Rectangles.Length == 2)
{
HaarRectangle a = Rectangles[0];
HaarRectangle b = Rectangles[1];
b.ScaleRectangle(scale);
b.ScaleWeight(weight);
a.ScaleRectangle(scale);
a.ScaledWeight = -(b.Area * b.ScaledWeight) / a.Area;
}
else // rectangles.Length == 3
{
HaarRectangle a = Rectangles[0];
HaarRectangle b = Rectangles[1];
HaarRectangle c = Rectangles[2];
c.ScaleRectangle(scale);
c.ScaleWeight(weight);
b.ScaleRectangle(scale);
b.ScaleWeight(weight);
a.ScaleRectangle(scale);
a.ScaledWeight = -(b.Area * b.ScaledWeight
+ c.Area * c.ScaledWeight) / (a.Area);
}
}