The keyword here is blob detection. Search OpenCV blob detection and I'm sure there are many examples.
One of the common methods is to use the Laplacian of Gaussian operator.
The Laplacian is a measure of the strength of the second-order derivatives. If you think of the blobs as peaks and valleys on a 3D surface, at the middle of the blobs the slope (derivative) of the surface is changing (second derivative) rapidly from negative to positive and vice-versa.
The Gaussian is there to average out this measurement over a wider area. Any area averaging kernel could be used, but the Gaussian is special* in that increasing the size of the kernel does not introduce any new features. Using multiple kernels creates a scale space, and allows you do scale invariant blob detection.
*I think the Poisson kernel can create a scale-space too with a slight rule relaxation.