zone.py is a small program which takes as input an image, distinguishes its colour zones and can do some operations, such as:
zone.py requires python, PIL (package python-imaging in Debian/Ubuntu) and scipy (package python-scipy in Debian/Ubuntu).
Just download the app (license: GPL 3.0), and run it (with “python zone.py image.ext”, or “./zone.py image.ext” after making it executable).
Run it with the “–help” argument to see available options.
There is no option to modify the “threshold” value which appears in the file for the simple reason that it isn't correctly supported (it may do what you want, but is incoherent, e.g. can change its behaviour if you just rotate the image).