1. A system comprising: one or more processors configured to: determine a foreground training region and a background training region of the image; determine foreground and background properties based on said foreground and background training regions; and compute foreground and background portions of the image by optimizing a first energy function, the first energy function comprising a function of the foreground and background properties, and the one or more processors configured to determine the foreground training region and the background training region of the image being further configured to: receive a user input defining a region of the image; on the basis of the user input, segment the image into a first portion comprising image elements having a foreground label and a second portion of image elements having a background label, the foreground label comprising a segmentation parameter which has a first value and the background label comprising a segmentation parameter which has a second value; define a second energy function comprising a combination of the first energy function and an additional term, the additional term comprising a combination of a scalar value and the segmentation parameter for an image element, summed over a plurality of image elements; optimize the second energy function using a plurality of different values of the scalar value to produce a plurality of optimization results, each optimization result defining a candidate foreground training region and a candidate background training region; and select one of the plurality of optimization results to provide the foreground and background training regions.