I would try something like this (let's call this the R'lyeh algorithm):
- Heavy gaussian blur (one third to one half of the image width)
- Threshold from black until you get some black pixels (ie, you try to keep the darkest pixels:
_,_,_,total,pixels,_=pdb.gimp_histogram(layer, HISTOGRAM_VALUE,0,0)
if pixels>0:
visually, at that point the layer is white with a few black spots, these black spots are the points further from the white in the initial image
- Make a rectangle selection on half the image and count the black pixels again (pdb.gimp_histogram() again. if there are none,continue here, otherwise continue with the other half (it can also be easier to curt in 4 and check the four quadrants). Then continue splitting and counting pixels until you are at a reasonable size (20x20) or as soon as you have all black points (total==pixels).
- Make a contiguous selection using the center of the selection as the starting point.
- You can actually follow all the selections where you find black pixels, and create contiguous selections from each (by adding them). This will cover the case of two disjoint oceans.