there are a lot of image processing libraries for C++ that includes the option to fill a given contours. If you are using 2D images I would suggest to use openCV. However, if you are using 3D images, ITK is a good choice.
Thanks for your answer. The question is that I do not want to use third-party libraries, like OpenCV or Matlab. I try to find some algorithms to do it efficiently.
To circumvent the seed(s) problem, you could do a reverse floodfill: assume the pixel in e.g. the upper-left corner is outside, use that corner as a seed for floodfill, and XOR the result.
Floodfill can be done recursively with an advancing front queue.