1. A method for processing an image comprising: receiving a user input identifying at least two objects within the image; generating an input mask based on the received user input; applying a geodesic filter to the input mask, the geodesic filter comprising an opening filtering operation that comprises a first erosion operation followed by a first dilation operation using a first structuring element and a closing filtering operation that comprises a second dilation operation followed by a second erosion operation using a second structuring element; and generating an output mask, the generated output mask being the same regardless of an order of applying the opening filtering operation and the closing filtering operation to the input mask.