The binary image segmentation problem can be reduced to finding a minimum cut in the graph induced by the image graph: the pixels are the vertices or nodes in the graph and we have edges between any neighbouring pixels in the horizontal and vertical direction (i.e. any vertex has maximum 4 neighbours).
Given an initial set of user specified foreground and background pixels (displayed as red and blue strokes) you can use these as sources and targets (or sources and sinks depending on the terminology) and find a minimum cut in this graph. After removing the edges in this cut, the pixels in the image will be disconnected such that each pixel in the image will be connected to either the source the target. If a pixel is connected to the source than it is a foreground pixel and if it is connected to the target than it is a background pixel.