Counting pixels with integral images