there is a plugin that is capable of identifying elements that are in view (ie: visible on page at the current scroll position)
I would bet if you thought it throw and mapped out the functionality, you’d be able to use it to tell if an image is in view…then you’d need to think through your process for getting that information to your counter
I do things like keep sort orders on images (not best for all use cases) and this allows me to match a sort number to a current cells index number
You might just have it so the plugin recognizes the image as being in view and then use the workflow events to set the custom state to the current cells index number