Good work @crokkon, implementing this feature had caused me some headaches and I did not test it on a large scale. I like your divide & conquer approach, he is simple, effective and stable.
The color in the histogram seems to be wrong. Lin. approx. in 1st iteration should be orange and not green.
.