localhist: implement region merging