This is tricky, it will depend on the quality of the image. Flood fill would be good (is there a library that implements this?) if boundaries are all solid, and the background is white, not grey, or off white. I did a quick scan of the internet and there are a few links to java code that may do it. Try searching for one that looks promising and see if it can be ported. I'm sure there is a 'proper' way to do it and you may just stumble across a quick or at least accurate method.