Finished most of segmentation. Now I need to output image and check for bugs.