Image analysis for object counting