Methods, apparatus and systems for processing interferograms in metrology applications are described. In one example aspect, a method includes obtaining an input phase image based on the interferograms, segmenting the input phase image by classifying the input phase image into multiple regions based on the phase value and a location of each pixel, assigning an integer value to each of the multiple regions, and constructing an output phase image based on the input phase image and the phase offset of each of the multiple regions.