Mathematically, you need a https://en.wikipedia.org/wiki/Complete_lattice
That allows you to define:
infimum and
supremum.
With those defined, anything outside of that is a gap.
What’s within is the object.
——
Practical use of a complete lattice is found in mathematical morphology, primarily used for medical imaging and geology. With it you can precisely define arbitrary limits and thereby define (circumscribe) “objects”.
From there you can: Count the # of bacteria, or estimate how many grains of sand are in a beach, etc, with just 2D or 3D photos or video.
=====