They do it by cheating. At first glance it looks like they cut all of the figures in half and transpose them, but they actually cut the top off of the far left figure without replacing it with the top of one of the figures on the right. They only cut the top of its hair off, so it still looks complete, but it has still been divided so it should only count as half a man. Then look at the tallest figure (the one whose head is the highest in the image). They do the same with his feet; they take them off on the right side but they don't replace them on the left. They only cut off the bottom half of them so he still looks like a complete human, but he has still been divided so he also only counts as half a man.
Given that, it starts out as 12 men, and ends up as 11 men + 1/2 man + 1/2 man. That still equals 12 men.
The average height is shorter after the transposition, which is how they make 13 figures (2 technically incomplete) out of the same number of pixels that the 12 complete figures were made up of.
A very clever trick.