Basically yes I'd like to select a left and a right limit. This could be done with the threshold tool.
I see I need to be more specific.
I'd like to use select a tonal range. The histogram I want because I find it easy to see the edge of a tonal region in a histogram. Imagine a bright sky with a dark foreground, you can easily discern the two peaks in a histogram.
Then I want to use the selected values to do some computation using overlay layers and masks.
This is a procedure I'm experimenting with so I was wondering if this could be automated using Gmic.