Techniques for counting objects in images