GIMP selection by example


I would like a tool for the GIMP that lets me select a set of pixels by giving examples of pixels that are and are not in that set. The selection would update interactively as example and counter-example pixels are specified.

Properties by which pixels might be distinguished:


and (here's the punchline)

Define a distance metric on these parameters, eg (difference in color)^2 + (difference in gradient)^2 + etc. A pixel is a member of the set if the nearest example (as measured by the metric) is closer than the nearest counter-example. If membership of the set is a parameter, this selection process would have to be iterated until it converged.