function to calculate the mask based on the velocity of the passing subjects. It is a inline pixel counting function.