Perhaps you could check if there is a group of 4 tiles. For example the left top tile group is invalid because you have a passible tile. Then you check whether if there is a possible group in the vertical or horizontal alignment and keep resizing the box until no solid tile is found. In case there is a group of 4 you check in either direction whether 2 of those tiles can form another 4. If not then you stop looking in that direction and keep the rectangle as is.
For each grouped tileset you also mark them as checked to make sure your algorithm does not check them again.
So in sequence:
etc. Simply go from top left to bottom right one tile at a time. If its solid check the algorithm. If the tile is already checked we skip those till we reach the last tile.
As long the rectangle can grow downwards and to the right equal in size you should cover it.