Is there way for polygon decomposition by thickness? Here is an example

dots representing coordinates of pixels





added more representative example





added real example



added main problem
It is a bad idea to try to abuse clustering algorithms for this. In particular k-means will not cut vertically, nor consider rectangles.

What you need to do is a trivial axis-aligned corner detection.it does not get much simpler than that!

You begin on the left, and whenever the location of the topmost pixel changes, a rectangle is complete.