Algorithms for materials science image segmentation