I have an image that contains more than one bounding box.

I need to extract everything that has bounding rectangles in them. So far from this site I have received this answer:
y = img[by:by+bh, bx:bx+bw] cv2.imwrite(string + '.png', y)
It works, however, it only gets one. How do I change the code? I tried to put it in an outline for outlines, but it still displays one image instead of several.
Thank you so much in advance.
source share