segmenting an image based on gradients using graph techniques