void f(unsigned char& r)
{
 r = (r >= threshold) ? : 1 : 0;
}

foreach(array.begin(), array.end(), f);

ダメかもしれんが。