You will need several things
- You will need to detect contours with a hierarchy, else only the outer contour is returned.
- Then you will need to have a look at how hierarchy works.
- Then you can couple the pixel intensities to the correct contour.
- Finally you can draw them starting with the largest one.