Calculate the binary reference image using k-means clustering with multi-cluster merging. K-means is run on the first npcs principal components to speed up the calculations.
npcs
Useful links