Ben Tupper and Mike Sieracki released the RATS: Robust Automatic Threshold Selection plugin, which determines local thresholds averaging the intensities weighted with the gradient. In effect, the values close to an edge have much more impact on the threshold than other values, which follows the intuition that the foreground is separated from the background by edges.