size_t cnt(const image& img) { size_t sum = 0; img.reset(); while (img.move_next()) { if (img.element()) sum++; } return sum; }