|   | 1 |  initial version  | 
you have to create your mask outside the loop.
#Create the basic black image
mask = np.zeros(blur.shape[:2], dtype="uint8")
for (x1,y1,x2,y2)in rect:
  cv2.rectangle(mask,(x1,y1),(x2,y2), (COLOR_WHITE), -1)
(silly noob error, isn't it ?)
|   | 2 |  No.2 Revision  | 
you have to create create your mask outside the loop.
#Create the basic black image
mask = np.zeros(blur.shape[:2], dtype="uint8")
for (x1,y1,x2,y2)in rect:
  cv2.rectangle(mask,(x1,y1),(x2,y2), (COLOR_WHITE), -1)
(silly noob error, isn't it ?)