I have a large dataset of SEM micrographs I am trying to binarily segment via ClusteringComponents, and it has seemed to be the most accurate method compared to the other binarization functions, e.g. Morphological Binarize.
However, while the clusters are accurate, it assigns the dark or light pixel groups in essentially random order. However I suspect that it occurs when the contrast is low.
I am able to reproduce this problem with example images. On the first image, the dark pixels are assigned 0, while on the second image, the light pixels are assigned 0.
test=ExampleData[{"TestImage","Man"}]
clustered=ClusteringComponents[test,2,PerformanceGoal->"Quality"];
Image[clustered - 1, "Bit"]
test2=ExampleData[{"TestImage","Tank2"}]
clustered2=ClusteringComponents[test2,2,PerformanceGoal->"Quality"]
How can I get it so it consistently assigns the dark pixel components to either 0 or 1??
FindClusters
, which itself doesn't offer a way to order clusters. $\endgroup$