Consider an effective energy consisting of boundary-energy and volume-constraint terms as in equation . After choosing the source () and destination () pixels (the cell index of the source will overwrite the target pixel if the index copy is accepted), we calculate the change in the effective energy that would result from the copy. We evaluate the change in the boundary energy and volume constraint as follows. First we visit the target pixel’s neighbors (). If the neighbor pixel belongs to a different generalized cell from the target pixel, i.e., when (see equation ), we decrease by . If the neighbor belongs to a cell different from the source pixel () we increase by .
The change in volume-constraint energy is evaluated according to: