Questions about greedy meshing(greedy parting actually)


This is what I do

ne.
first I turned a bmp file into parts. me computer explode.
I optimized it by merging same color parts horizontally you see.
but I have no Idea how to merge these vertically.

also I have question
I read greedymeshing algorithm.
left one works correctly. but right one, number of parts increases. am I understanding wrong? is this normal or how to prevent this? and thank you