I been messing with Python and OpenCV on some images, and kind of got the result I want. Here is an example of the output image.
So the important part is opencv has draw red rectangles around the objects it has identified (I don't want to share what the original image was so yes those gray patches are all the remain after running a lot of functions on the image).
Now what I want to do is expand the rectangles (there are 2 here, but 3 or 4 are also possible) so they are as large as possible without touching. I just can't seem to come up with any kind of algorithm to do that. Any suggestions?