I described a rectangle’s weight back in 50000 Rectangles #2. This weight could also be considered opacity, or its inverse, transparency.
I keep track of the total weight on each pixel. Each time a rectangle covers a pixel the rectangle weight is added to the pixel weight.
All rectangles, and all pixels covered by each rectangle are assigned the same weight. So the pixel weight is essentially the number of rectangles that intersect the pixel.
Weight varies from image to image, but on a single image it is constant. At least so far. I may experiment with rectangles of different weight, or different pixel weights within a rectangle.