I might be wrong but to me this looks very similar as the input
Yes, but the regions have been assigned distinct numbers. (Looking closely, you'll see that the clump of "B"s in the top right corner is given a different number than the clump of "B"s in the bottom left.)