Partitioning a 2D Image