Would be nice to have at least one image to understand your problem.
In general, you can use contours or connected component with stats to get the two biggest components on a binary image.
And simple blob detector can be handy to non binary images.