Complete Grabcut algorithm part.