Select a random pixel as the starting pixel. This becomes region A. Extend A repeatedly until A becomes larger. This is your area.
The extension method of A is to search for neighboring pixels in A, so that they have the same color for at least one neighboring pixel in A.
What "similar color" means to you is somewhat variable. If you can make exactly two colors, as you say in another answer, then โsimilarโ is โequalโ. Otherwise, โlikeโ will mean colors that have RGB values โโor not everything, where each component of the two colors is in small numbers from each other (that is, 255, 128, 128 is similar to 252, 125, 130).
You can also limit the selected pixels to look like a seed pixel, but this works better when a person selects a seed. (I believe that this is what is done in Photoshop, for example.)
This may be better than edge detection, because you can deal with gradients without filtering them out of existence, and you do not need to process the resulting detected edges in a consistent area. The disadvantage is that the gradient can go all the way from black to white, and it will register as the same area, but it may be what you want. In addition, you must be careful with the implementation, otherwise it will be too slow.
jprete
source share