Phase unwrapping refers to the determination of phase from modulo 2pi data, some of which may not be reliable. In 2D, this is equivalent to confining the support of the phase function to one or more arbitrarily shaped regions. A phase unwrapping algorithm is presented which works for 2D data known only within a set of nonconnected regions with possibly nonconvex boundaries. The algorithm includes the following steps: segmentation to identify connectivity, phase unwrapping within each segment using a Taylor series expansion, phase unwrapping between disconnected segments along an optimum path, and filling of phase information voids. The optimum path for intersegment unwrapping is determined by a minimum spanning tree algorithm. Although the algorithm is applicable to any 2D data, the main application addressed is magnetic resonance imaging (MRI) where phase maps are useful.