This functionality was originally introduced to remove inclusions of certain phases within another phase. We are however simply looking for neighbouring pixels here. As this is still effective with small inclusions, for larger ones, repeated calls of this function may be required. Note however that this also affects pixels of the phase to modify that are not inclusions but just neighbouring pixels of the target phase.
phase_merge(img, phase, into)
A 2D array.
The phase to modify.
The phase to change pixels to.
The modified 2D array.