Grasp algorithm implementation for segmentation of images.