Hello everyone! I have an random shape (an array with positions of squares 1*1), I need to split it into rectangles and make an array that stores the beginning and end of each rectangle. I need to run it in C#. Near is an example of a shape before and after splitting into rectangles. There should be a minimum number of rectangles.
Looks like you probably want a run length encoding (RLE) scheme. The above looks like it had an RLE pass laterally to make scanlines worth of boxes, then merged vertically if they were the same size.

